I’m trying to create a code in visual basic to automatically send e-mails from Lotus Notes. Below code works fine, the trouble is that sender of note is always the user logged on to notes - and I would like it to be task-id. So when recipient receives e-mail and press reply, it will go back to task-id.
Dim Maildb As Object
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
'Start a session to notes
Set Session = CreateObject(“Lotus.NotesSession”)
'This line prompts for password of current ID noted in Notes.INI
Call Session.Initialize
'Open the mail database in notes
Set Maildb = Session.GETDATABASE(“”, “mail03\2435t.nsf”)
If Not Maildb.IsOpen = True Then
Call Maildb.Open
End If
'Create the mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.ReplaceItemValue(“Form”, “Memo”)
'Set the recipient
Call MailDoc.ReplaceItemValue(“SendTo”, “user@mail.com”)
'Set subject
Call MailDoc.ReplaceItemValue(“Subject”, “test”)
'Create and set the Body content
Set Body = MailDoc.CREATERICHTEXTITEM(“Body”)
Call Body.APPENDTEXT(“Line 1”)
'Example to create an attachment (optional)
Call Body.ADDNEWLINE(2)
'Call Body.EMBEDOBJECT(1454, “”, “C:\filename”, “Attachment”)
'Example to save the message (optional)
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
'Gets the mail to appear in the Sent items folder
Call MailDoc.ReplaceItemValue(“PostedDate”, Now())
Call MailDoc.send(False)
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing
Thank you!