Hi There,
I have a script library, and in there i would like to send a mail with a doc link to the relevent document. here is the code in the script :
Sub SendEmail(w,uidoc,strstatus)
'declare variables
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim maildoc As NotesDocument
Dim strStatusDesc As String
'Set the variables
Set db = s.CurrentDatabase
Set doc = uidoc.document
Set maildoc = New NotesDocument(db)
Set rtitem = New NotesRichTextItem(maildoc, "Body")
'Assign a User-Friendly quote to the status number
If strstatus = "5" Then
strStatusDesc = "Awaiting Quote."
Elseif strstatus = "10" Then
strStatusDesc = "Awaiting Authorisation."
Elseif strStatus = "15" Then
strStatusDesc = "Order Placed."
Elseif strstatus = "20" Then
strStatusDesc = "Order Delivered"
Elseif strstatus = "25" Then
strStatusDesc = "Order Dispatched"
End If
'Prepare subject and body text
maildoc.subject = "Your I.T. Order is at status : " & strStatusDesc
maildoc.SendTo = doc.UName(0)
maildoc.Body = "Hello"
'Attach DocLink
Call rtitem.AppendDocLink(doc,"Your Order","")
'Send Mail
maildoc.Send(False)
End Sub
i am not sure what is going wrong, it is sending the mail, but there is not doclink on it.
Can anyone point me in the right direction?
Thanks
F1H
Subject: AppendDocLink in Script not working
You define the Body as a rich text field and then set body=“hello”, that effectively changes its type to Text.
Rather body.appendtext(“Hello”)
and then appenddoclink
Basically always use Richtext methods when dealing with rich text fields.
Subject: RE: AppendDocLink in Script not working
Hi good day!
I have this same problem, I already checked my scripts and I think I applied what your suggestion. But still I don’t see my link to show in the mail. Here is my codes:
Option Public
Sub Initialize
ChkFlg = 0
Call SendMail
If ChkFlg = 1 Then
Exit Sub
End If
End Sub
Function F_Settei(doc As NotesDocument)As String
F_Settei=""
If doc.SendT(0)<>"" Then
tim$=Right("00"+Trim(Str(Hour(doc.SendT(0)))),2)+":"+Right("00"+Trim(Str(Minute(doc.SendT(0)))),2)
Select Case doc.SendD(0)
Case "1":F_Settei=Str(doc.SendD_1(0))+" "+tim$+" only"
Case "M":F_Settei="毎月"+Str(doc.SendD_M(0))+" day/s"+tim$
Case "W":
Forall x In doc.SendD_W
Select Case x
Case "1" :w$=w$+"(Sunday)"
Case "2" :w$=w$+"(Monday)"
Case "3" :w$=w$+"(Tuesday)"
Case "4" :w$=w$+"(Wednesday)"
Case "5" :w$=w$+"(Thursday)"
Case "6" :w$=w$+"(Friday)"
Case "7" :w$=w$+"(Saturday)"
End Select
End Forall
F_Settei$="Weekly "+w$+tim$
End Select
End If
End Function
Function SendMail As Integer
On Error 4294 Goto Err4294'4294: メールを送信できません。アドレス帳に該当する名前が見つかりません。
Dim ws As New NotesUIWorkspace
Dim udc As NotesUIDocument
Dim doc_w As NotesDocument
Dim dc As NotesDocument
Dim cdc As NotesDocument
Set udc = ws.CurrentDocument
Set cdc = udc.Document
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Set doc_w = db.CreateDocument
'added for the purpose of setting the FROM/Sender name
Dim sender As String
'sender = udc.FieldGetText("AddUserID")
sender = "Admin"
'added for the purpose of setting the FROM/Sender name
doc_w.SaveOptions ="0"
doc_w.Principal = sender + "/U/SHI"
doc_w.From = sender
doc_w.AltFrom = sender
doc_w.SendFrom = sender
doc_w.INetFrom = sender
doc_w.tmpDisplaySentBy = sender
doc_w.tmpDisplayFrom_Preview = sender
doc_w.DisplaySent = sender
doc_w.SendTo =udc.FieldGetText("SendTo")
doc_w.CopyTo =udc.FieldGetText("CopyTo")
doc_w.BlindCopyTo =Split(udc.FieldGetText("BlindCopyTo"))
doc_w.Subject ="【予約依頼承認待ち】⇒SDMI予約DB"
If Not(Isnull(doc_w.SendTo)) Then
Dim item_w As NotesRichTextItem
Set item_w = New NotesRichTextItem( doc_w, "Body" )
Call item_w.AppendText(Chr(13)+"SHI DESIGNING & MANUFACTURING, INC.")
Call item_w.AppendText(Chr(13)+"Dear Ms. Rhen,")
Call item_w.AddNewLine(1)
Call item_w.AddNewLine(1)
Call item_w.AppendText(Chr(13)+"Good Day!")
Call item_w.AddNewLine(1)
Call item_w.AddNewLine(1)
Call item_w.AppendText(Chr(13)+"Please be informed that there is new request for reservation.")
Call item_w.AddNewLine(1)
Call item_w.AppendText(Chr(13)+ "Ref. No.: 「" + udc.FieldGetText("refNo") + "」 ==> " )
Call item_w.Appenddoclink(cdc,"Please click once")'保存済のDoclinkを送る(注:自分自身を送らないこと
Call item_w.AppendText(") (This link doesn't work on non-Lotus email)" )
Call item_w.AddNewLine(1)
Call item_w.AddNewLine(1)
Call item_w.AppendText(Chr(13)+"--------------------------------------------------------------------------")
Call item_w.AppendText(Chr(13)+"This address is only for transmission. Please do not perform a reply")
Call item_w.AppendText(Chr(13)+"--------------------------------------------------------------------------")
Call doc_w.Send(False)
End If
SendMail = 1
Exit Function
Err4294:
Print "4294: メールを送信できません。アドレス帳に該当する名前が見つかりません:UNID=" & doc.UniversalID
Exit Function
End Function
Can you point me out what I am missing?
Thank you very much.
Best regards,
OSO
Subject: RE: AppendDocLink in Script not working
Thanks Sue,
Thats working fine now.
Thanks again,
F1H
Subject: AppendDocLink in Script not working
hi Check in your database no Default view are there …
untill unless have one difault view to send doclink
thanks
rupesh
Subject: RE: AppendDocLink in Script not working
Thanks for your post,
I only have one view in the database at this time, it is named and labelled as the default view.
Any other suggestions?
Thanks for any help!
F1H