Hi all,
I worked on this code to be able to send email blast to my customers with individualized information. However im not sure how to add an attachment file (same for all emails) and i need this email to go out not from my personal email but from a shared email i have Access to. This is through lotus notes.
Anyone that could give me a hand?
Regards,
CODE:
Sub send_email()
Dim sSignature, oWorksheet, oNotesSession, oMailDBName, oNotesMail, bDebug
On Error GoTo 0
Set oWorksheet = Application.ActiveWorkbook.Worksheets.Item(1)
Set oNotesSession = CreateObject("Notes.NotesSession")
bDebug = True
Set oMailDB = oNotesSession.GETDATABASE("", "")
If oMailDB.IsOpen = True Then
If bDebug Then MsgBox ("Mail database for user " & sUserName & " is already open.")
Else
If bDebug Then MsgBox ("Opening mail database for user " & sUserName)
oMailDB.OPENMAIL
End If
sSignature = oMailDB.GETPROFILEDOCUMENT("CalendarProfile").GETITEMVALUE("Signature")(0)
iRow = 1
Do While oWorksheet.Cells(iRow, 1).Value <> "" And iRow <= 300000
If bDebug Then MsgBox ("Processing line " & iRow & ": " & oWorksheet.Cells(iRow, 6).Value)
Set oNotesMail = oMailDB.CreateDocument
oNotesMail.Form = "Memo"
oNotesMail.SendTo = oWorksheet.Cells(iRow, 2).Value
oNotesMail.Subject = "RMA Replacement Follow Up for " & oWorksheet.Cells(iRow, 1).Value
oNotesMail.Body = "We show RMA " & oWorksheet.Cells(iRow, 6).Value & " pending to return, the expected part is " & oWorksheet.Cells(iRow, 8).Value & " a scheduled invoice for the full retail price will be generated if you fail to return the damaged part." & Chr(10) & " " & Chr(10) & "Should you have any questions please call us back at 1-800-800-9511 option 1 and refer to RMA " & oWorksheet.Cells(iRow, 6).Value & "." & Chr(10) & " " & Chr(10) & oWorksheet.Cells(iRow, 12).Value & vbCrLf & "" & Chr(10) & oWorksheet.Cells(iRow, 13).Value & vbCrLf & ""
oNotesMail.SaveMessageOnSend = True
Dim AttachME As Object
oNotesMail.Attachment1 = "C:\Users\19018233\Desktop\Returns.jpg"
If Attachment1 <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
Set EmbedObj1 = AttachME.embedobject(1454, "attachment1", "C:\Users\19018233\Desktop\Returns.jpg", "") 'Required File Name
End If
oNotesMail.PostedDate = Now()
oNotesMail.Send 0, oWorksheet.Cells(iRow, 2).Value
Set oNotesMail = Nothing
iRow = iRow + 1
Loop
If bDebug Then MsgBox ("Finished after processing " & (iRow - 1) & " lines.")
Set oMailDB = Nothing
Set oNotesSession = Nothing
End Sub
Bookmarks