Hello new guy to forum and VBA for that matter... but need some help...
Ok, So I am trying to creat a looping code that will grab emails from 1 list and populate them in my code that I use to send auto send emails in lotus notes, and then pick the attachment location from another list in excel... So essentially I am looking to send 1 specific file (pdf's) to a specific person... than loop to pick the next person in the list and the next location... so the end result would be that I have sent 10 emails with attachments to 10 different recipients with a unique file attached to each. Below is my code that I sue to attach and send emails from excel through Lotus notes...
'Starting to build email
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean
Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler
'Building Message
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "Budget File"
oDoc.sendto = "[email protected]"
oDoc.body = "whatever I would like to type same message for all recipients."
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True
'Attaching DATABASE
Call oItem.EmbedObject(1454, "", "H:\example.pdf")
oDoc.visable = True
'Sending Message
oDoc.SEND False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End Sub
Bookmarks