funkmonsteruk
IS-IT--Management
I have used the following code to e-mail a workbook (using Lotus Notes)to a single address:
Private Sub send_mail()
Dim Maildb As Object 'the mail database
Dim username As String
Dim maildbname As String
Dim maildoc As Object
Dim attachme As Object
Dim session As Object
Dim embedobject As Object
Dim mytime As String
Dim recipient As String
Dim subject As String
Dim attachment As String
Dim BodyText As String
recipient = "Andy P Smith\HBEU\HSBC@HSBC"
subject = " PSM Diary"
attachment = "C:\My Diary.xls"
BodyText = "Diary"
Set session = CreateObject("Notes.NotesSession"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
username = session.username
Set Maildb = session.GETDATABASE("", maildbname)
If Maildb.ISOPEN = True Then
Else
Maildb.OPENMAIL
End If
Set maildoc = Maildb.CREATEDOCUMENT
maildoc.Form = "Memo"
maildoc.sendto = recipient
maildoc.subject = subject
maildoc.Body = BodyText
If attachment <> "" Then
Set attachme = maildoc.CREATERICHTEXTITEM("Attachment"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set embedobject = attachme.embedobject(1454, "", attachment, "Attachment"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
End If
maildoc.PostedDate = Now()
maildoc.send 0, recipient
Set Maildb = Nothing
Set maildoc = Nothing
Set attachme = Nothing
Set session = Nothing
MsgBox "Mail sent ro" & recipient & "re:" & subject
End Sub
However i need to send the workbook to several addresses at once, is it possible to reference a list of e-mail addresses to send the workbook to or do i have to add names individually to the code?
For example replacing the recipient = "address" line with a Recipient= Variable line in which the variable is a list of e-mail addresses
Private Sub send_mail()
Dim Maildb As Object 'the mail database
Dim username As String
Dim maildbname As String
Dim maildoc As Object
Dim attachme As Object
Dim session As Object
Dim embedobject As Object
Dim mytime As String
Dim recipient As String
Dim subject As String
Dim attachment As String
Dim BodyText As String
recipient = "Andy P Smith\HBEU\HSBC@HSBC"
subject = " PSM Diary"
attachment = "C:\My Diary.xls"
BodyText = "Diary"
Set session = CreateObject("Notes.NotesSession"
username = session.username
Set Maildb = session.GETDATABASE("", maildbname)
If Maildb.ISOPEN = True Then
Else
Maildb.OPENMAIL
End If
Set maildoc = Maildb.CREATEDOCUMENT
maildoc.Form = "Memo"
maildoc.sendto = recipient
maildoc.subject = subject
maildoc.Body = BodyText
If attachment <> "" Then
Set attachme = maildoc.CREATERICHTEXTITEM("Attachment"
Set embedobject = attachme.embedobject(1454, "", attachment, "Attachment"
End If
maildoc.PostedDate = Now()
maildoc.send 0, recipient
Set Maildb = Nothing
Set maildoc = Nothing
Set attachme = Nothing
Set session = Nothing
MsgBox "Mail sent ro" & recipient & "re:" & subject
End Sub
However i need to send the workbook to several addresses at once, is it possible to reference a list of e-mail addresses to send the workbook to or do i have to add names individually to the code?
For example replacing the recipient = "address" line with a Recipient= Variable line in which the variable is a list of e-mail addresses