Hi,#
I use the following code to send mail to a person through lotus notes. But i want to send a specific page or the Range like (A1 : K50) as an attachment. Someone please help me to alter the code so that it works in the way i want it to.
I use the following code to send mail to a person through lotus notes. But i want to send a specific page or the Range like (A1 : K50) as an attachment. Someone please help me to alter the code so that it works in the way i want it to.
Code:
Public Sub CommandButton21_Click()
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:\Users\janabh1\AppData\Local\Lotus\Notes\Data\mail\Lippstadt\janabh1.nsf")
If Not Maildb.IsOpen = True Then Call Maildb.Open
'Create the Mail Document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
'Set the Recipient of the mail
Call MailDoc.REPLACEITEMVALUE("SendTo", "Bharathwaj Janaki Krishnamoorthi")
'Set subject of the mail
Call MailDoc.REPLACEITEMVALUE("Subject", "Data")
'Create and set the Body content of the mail
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Please ignore the message")
'Example to create an attachment (optional)
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", "C:\Users\janabh1\Desktop\Prüfungen.xlsx\", "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