I found Nate Oliver's code (below) and tried it to send an email, including attaching the active workbook through the workbook using Lotus Notes. It works as advertised, except the workbook doesn't attach. The recipients, subject and body are all fine. I noticed the original post was from 2006, so it is possible some code has been updated for assigning attachments?
Thanks in advance.
Michel
Office 2007
Option Explicit
Sub LotusNotsSendActiveWorkbook()
****'**** Send an e-mail & attachment using Lotus Not(s)
****'**** Original Code by Nate Oliver (NateO)
****'**** Declare Variables for file and macro setup
****Dim UserName As String, MailDbName As String, Recipient As String, attachment1 As String
****Dim Maildb As Object, MailDoc As Object, AttachME As Object, Session As Object
****Dim EmbedObj1 As Object
****With Application
********.ScreenUpdating = False
********.DisplayAlerts = False
******' Open and locate current LOTUS NOTES User
********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 = True Then
********Else
************Maildb.OPENMAIL
********End If
****
******' Create New Mail and Address Title Handlers
********Set MailDoc = Maildb.CreateDocument
****
********MailDoc.Form = "Memo"
********'** Select range of e-mail addresses
********Recipient = Sheets("E-Mail Addresses").Range("A2").Value
********'** Or send to a signle address
********'** Recipient = "yourname@isp.com"
********MailDoc.SendTo = Recipient
********
********'** Subject & Body stored in a**worksheet
********MailDoc.Subject = Sheets("E-Mail Addresses").Range("B2").Value
********MailDoc.Body = Sheets("E-Mail Addresses").Range("C2").Value
********'** These can be entered here manually instead
********'** MailDoc.Subject = "Check this out!"
********'** MailDoc.Body = "Made you look!"
****
****'** Select Workbook to Attach to E-Mail
********MailDoc.SaveMessageOnSend = True
********MsgBox ActiveWorkbook.Name
************attachment1 = ActiveWorkbook.Name
****
********If attachment1 <> "" Then
************On Error Resume Next
****************Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
****************Set EmbedObj1 = AttachME.embedobject(1454, "attachment1", ActiveWorkbook.Name, "")
************On Error Resume Next
********End If
****
********MailDoc.PostedDate = Now()
************On Error GoTo errorhandler1
********MailDoc.Send 0, Recipient
****
********Set Maildb = Nothing
************Set MailDoc = Nothing
****************Set AttachME = Nothing
************Set Session = Nothing
********Set EmbedObj1 = Nothing
****
********.ScreenUpdating = True
********.DisplayAlerts = True
****End With
****
errorhandler1:
****
********Set Maildb = Nothing
************Set MailDoc = Nothing
****************Set AttachME = Nothing
************Set Session = Nothing
********Set EmbedObj1 = Nothing
****
End Sub
Thanks in advance.
Michel
Office 2007
Option Explicit
Sub LotusNotsSendActiveWorkbook()
****'**** Send an e-mail & attachment using Lotus Not(s)
****'**** Original Code by Nate Oliver (NateO)
****'**** Declare Variables for file and macro setup
****Dim UserName As String, MailDbName As String, Recipient As String, attachment1 As String
****Dim Maildb As Object, MailDoc As Object, AttachME As Object, Session As Object
****Dim EmbedObj1 As Object
****With Application
********.ScreenUpdating = False
********.DisplayAlerts = False
******' Open and locate current LOTUS NOTES User
********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 = True Then
********Else
************Maildb.OPENMAIL
********End If
****
******' Create New Mail and Address Title Handlers
********Set MailDoc = Maildb.CreateDocument
****
********MailDoc.Form = "Memo"
********'** Select range of e-mail addresses
********Recipient = Sheets("E-Mail Addresses").Range("A2").Value
********'** Or send to a signle address
********'** Recipient = "yourname@isp.com"
********MailDoc.SendTo = Recipient
********
********'** Subject & Body stored in a**worksheet
********MailDoc.Subject = Sheets("E-Mail Addresses").Range("B2").Value
********MailDoc.Body = Sheets("E-Mail Addresses").Range("C2").Value
********'** These can be entered here manually instead
********'** MailDoc.Subject = "Check this out!"
********'** MailDoc.Body = "Made you look!"
****
****'** Select Workbook to Attach to E-Mail
********MailDoc.SaveMessageOnSend = True
********MsgBox ActiveWorkbook.Name
************attachment1 = ActiveWorkbook.Name
****
********If attachment1 <> "" Then
************On Error Resume Next
****************Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
****************Set EmbedObj1 = AttachME.embedobject(1454, "attachment1", ActiveWorkbook.Name, "")
************On Error Resume Next
********End If
****
********MailDoc.PostedDate = Now()
************On Error GoTo errorhandler1
********MailDoc.Send 0, Recipient
****
********Set Maildb = Nothing
************Set MailDoc = Nothing
****************Set AttachME = Nothing
************Set Session = Nothing
********Set EmbedObj1 = Nothing
****
********.ScreenUpdating = True
********.DisplayAlerts = True
****End With
****
errorhandler1:
****
********Set Maildb = Nothing
************Set MailDoc = Nothing
****************Set AttachME = Nothing
************Set Session = Nothing
********Set EmbedObj1 = Nothing
****
End Sub