automation of signature in vb

Joined
Jul 25, 2007
Messages
2
Reaction score
0
can ne one help me in finding a way for automatic insert of signatur in lotus from vb, i have a form when i click send i am able to attach a txt and body to lotus but for some reason i m not able to get the signature in the body which i normally get when i do normal compose , i have the signature setting in mail preferences , i m not able to find why my notus is not able to bring the sgnature when i m doing it from VB , it also workd ok when i do it from ACCess
heres my code
Dim MySubject As String
Dim MyBodyText As String
Dim MyReceiver As String
Dim MyAttachment As String
MyReceiver = Me.TxtEmailAddress
MySubject = " "
MyAttachment = "C:\ApplicationForm.pdf"
MyBodyText = "Username : " & Me.TxtUserName & vbCrLf & _
"password : " & Me.TxtPassword
Call SendNotesMail(MySubject, MyAttachment, MyBodyText, MyReceiver)
End Sub

Public Sub SendNotesMail(Subject As String, Attachment As String, BodyText As String, SendTo As String)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim intAttach As Integer
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim Server As String

On Error GoTo LotusNotesFail

'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
Server = Session.GetEnvironmentString("MailServer", True)
MailDbName = Session.GetEnvironmentString("MailFile", True)
UserName = Session.UserName

'Open the mail database in notes
Set Maildb = Session.GetDatabase(Server, MailDbName)

'Set up the new mail document
Set MailDoc = Maildb.CreateDocument

With MailDoc
.Form = "Memo"
.SendTo = SendTo
.Subject = Subject
.SaveMessageOnSend = SaveIt

'Set up the embedded object and attachment and attach it
Dim aryAttachment() As String

aryAttachment = Split(Attachment, "|")
Dim ric As Object
Set ric = .CreateRichTextItem("Body")
ric.AppendText BodyText & Chr$(13)
' Call ric.AppendText("Line1" & vbCrLf & "Line2")
For intAttach = LBound(aryAttachment) To UBound(aryAttachment)
Set EmbedObj = ric.EmbedObject(1454, "", aryAttachment(intAttach), "Attach")
Next intAttach
.Save False, False

'Send the document
'.PostedDate = Now() 'Gets the mail to appear in the sent items folder
'.Send False
End With

DoEvents
Dim ws As Object
Set ws = CreateObject("notes.notesuiworkspace")
DoEvents
ws.OpenDatabase Server, MailDbName
ws.EDITDOCUMENT True, MailDoc

'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set ric = Nothing
Set ws = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
Exit Sub

LotusNotesFail:
MsgBox ("Cannot open new memo in Lotus Notes. Please make sure you have Lotus Notes running in your computer.")

End Sub
 
Back
Top