I have been trying to do exactly the same thing except using MAPI as we have Novell Groupwise. This code uses message boxes for convenience, however, the attachment doesn't actually get attached - it is only attaching a reference to the file attached. Therefore, when the recipient tries to open it, Groupwise comes up with an error. Does anybody know how to solve this?
I am running Excel 2000 & Groupwise 5.5
Thanks
Tiglet
Sub MapiSendMail()
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Dim sProfile As String
Dim sSubjPrmpt As String
Dim sTextPrmpt As String
Dim sEmailPrmpt As String
Dim sMsgTitle As String
sProfile = "Novell Default Settings"
sEmailPrmpt = "Enter valid Email Name of message recipient:"
sSubjPrmpt = "Enter the subject line for this message:"
sTextPrmpt = "Enter the text for this message:"
sMsgTitle = "Mapi Macro"
' Create the Session Object.
Set objSession = CreateObject("MAPI.session")
' Log on using the session object.
objSession.Logon profileName:=sProfile
' Add a new message object to the OutBox.
Set objMessage = objSession.Outbox.Messages.Add
' Set the properties of the message object.
objMessage.Subject = InputBox(sSubjPrmpt, sMsgTitle)
objMessage.Text = InputBox(sTextPrmpt, sMsgTitle)
' Add a recipient object to the objMessage.Recipients collection.
objMessage.Attachments.Add ("c:\temp\B4000.xls")
Set objRecipient = objMessage.Recipients.Add
' Set the properties of the recipient object.
objRecipient.Name = InputBox(sEmailPrmpt, sMsgTitle)
objRecipient.Resolve
objMessage.Send showdialog:=False
MsgBox "Message sent successfully!"
' Log off using the session object.
objSession.Logoff