AnotherHiggins
Technical User
We are switching from GroupWise to Lotus Notes at work.
I have several reports that I format and send out via macros. Everything has been working beautifully with GW, but I'm having some trouble configuring the code for Lotus Notes.
I should note that I'm not really a programmer - I'm completely self-taught on the job and have come about whatever skills I do have because I am a lazy, lazy man who hates routine "busy work".
anyway, I'll attach the basic code I'm using. I found this here on TT and it is working in most cases, but I have a handful of emails that should be sent out with multiple attachments. I can't seem to pass an array through to the code and get it to work.
I've considered copying all files that are to be attached to a temporary holding area, the looping through whatever files are there and attaching each one - but no joy, I just can't figure it out.
Any help would be greatly appreciated!
[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]
Help us help you. Please read FAQ181-2886 before posting.
I have several reports that I format and send out via macros. Everything has been working beautifully with GW, but I'm having some trouble configuring the code for Lotus Notes.
I should note that I'm not really a programmer - I'm completely self-taught on the job and have come about whatever skills I do have because I am a lazy, lazy man who hates routine "busy work".
anyway, I'll attach the basic code I'm using. I found this here on TT and it is working in most cases, but I have a handful of emails that should be sent out with multiple attachments. I can't seem to pass an array through to the code and get it to work.
I've considered copying all files that are to be attached to a temporary holding area, the looping through whatever files are there and attaching each one - but no joy, I just can't figure it out.
Any help would be greatly appreciated!
Code:
Public Sub SendNotesMail(strSavePath, strSubject, strBody, strAddressee)
'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 AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'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
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = strAddressee
MailDoc.Subject = strSubject
MailDoc.Body = strBody
MailDoc.SAVEMESSAGEONSEND = False
'Set up the embedded object and attachment and attach it
Attachment = strSavePath
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
' MailDoc.CREATERICHTEXTITEM ("Attachment")
'Send the document
MailDoc.Send 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]
Help us help you. Please read FAQ181-2886 before posting.