Hello,
Please help me with this one! I am desperately in need of a solution that will let me send a mail from an excel file to a Lotus Notes ID with the same excel file or any other excel file as an attachment.
I have tried using this code by mathew_guilbault from another Excel forum. But it only sends the message, not the attachment:
Sub SendMail()
Dim Maildb As Object, UserName As String, MailDbName As String
Dim MailDoc As Object, Session As Object
Dim tmax As String
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, _
(Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GetDataBase("", MailDbName)
If Maildb.IsOpen Then
Else: Maildb.OpenMail
End If
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
Recipients = "xyz@abc.com"
MailDoc.sendto = Recipients
'Nickname or full address
'MailDoc.CopyTo = Whomever
'MailDoc.BlindCopyTo = Whomever
MailDoc.Subject = "====> Test Mail - Please do not reply!! <===="
MailDoc.Body = _
Replace("Hi! Hope this mail arrives with an attachment!" _
& [b65536].End(3) & "Have a nice day!", "!", vbCrLf)
' Select Workbook to Attach to E-Mail
MailDoc.SaveMessageOnSend = True
tmax = ActiveWorkbook.Name
attachment1 = tmax
If attachment1 <> "" Then
On Error Resume Next
Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
Set EmbedObj1 = AttachME.embedobject(1454, "attachment1", tmax)
On Error Resume Next
End If
MailDoc.PostedDate = Now
On Error Resume Next
Call MailDoc.Send(False)
Session.Quit
Set Maildb = Nothing: Set MailDoc = Nothing: Set Session = Nothing
MsgBox ("message sent")
End Sub
I am on the brink of a nervous breakdown here!! Please help.....
Thanks a million in advance,
Mister Macro
Bookmarks