Hello,
I'm trying to send an excel file via Lotus Notes. Excel file currently sends through Outlook - need to now send through Lotus Notes. Sends by a macro button in a form and the excel file is open in the email when i'ts received, with an approval button that then sends it to another email address as well as returns it to the sender. I tried to start simplistically by just sending a small unrelated document through Lotus Notes by using the following code before updating existing Outlook code to ensure that it works correctly first (however it seems to be stop working around "Set MailDoc = Maildb.CREATEDOCUMENT"):
Sub Send_Email_via_Lotus_Notes()
Dim Maildb As Object
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
'Start a session of Lotus Notes
Set Session = CreateObject("Lotus.NotesSession")
'This line prompts for password of current ID noted in Notes.INI
Call Session.Initialize
'or use below to provide password of the current ID (to avoid Password prompt)
'Call Session.Initialize("<password>")
'Open the Mail Database of your Lotus Notes
Set Maildb = Session.GETDATABASE("", "C:\Program Files (x86)\IBM\Notes\notes.exe")
Set Session = CreateObject("Notes.Notessession")
'Create the Mail Document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
'Set the Recipient of the mail
Call MailDoc.REPLACEITEMVALUE("SendTo", "[email protected]")
'Set subject of the mail
Call MailDoc.REPLACEITEMVALUE("Subject", "Subject Text")
'Create and set the Body content of the mail
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
'Example to create an attachment (optional)
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", "C:\hello.xls", "Attachment")
'Example to save the message (optional) in Sent items
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 the Object variables - Recover memory
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing
End Sub
Display More
Moderator Note: I have added code tags for you today. Please read the rules that you agreed to and abide by them in the future.
Please help!