Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendObject - Lotus Notes

Status
Not open for further replies.

LebronJames

Programmer
Apr 5, 2003
93
0
0
I would like to use the SendObject (macro) and send the email VIA Lotus Notes.

If this cannot be done, is there a workaround? I need to run it as a macro..
 
Try this code I got from somewhere on the web, call the sub with the relevant parameters. It works for me.

'Public Sub SendNotesMail(Subject as string, attachment as string,
'recipient as string, bodytext as string,saveit as Boolean)
'This public sub will send a mail and attachment if neccessary to the
'recipient including the body text.
'Requires that notes client is installed on the system.
Public Sub SendNotesMail(Subject As String, attachment As String, recipient() As Variant, bodytext As String, saveit As Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim Server$
Dim MailFile$
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim hwnd As Long
Dim i As Integer

If hwnd = FindWindow("Notes", 0) < 0 Then
MsgBox "ERR: Please open and Login to Lotus notes to Continue"
Else
'Next line only works with 5.x and above. Replace password with your password
'Session.Initialize ("password")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string or using above password you can use other mailboxes.
Set Session = CreateObject("Notes.NotesSession")
Server$ = Session.GETENVIRONMENTSTRING("MailServer", True)
MailFile$ = Session.GETENVIRONMENTSTRING("MailFile", True)
'Open the mail database in notes
Set Maildb = Session.GETDATABASE(Server$, MailFile$)
'Set up the new mail document
For i = 0 To UBound(recipient())
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = recipient(i)


MailDoc.Subject = Subject
MailDoc.Body = bodytext
MailDoc.SAVEMESSAGEONSEND = saveit
'Set up the embedded object and attachment and attach it
If attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", attachment, "Attachment")
' MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.SEND 0, recipient
Next i
End If
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing

End Sub


"When the going gets wierd, the wierd turn pro" - R. Duke
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top