G
Georgie8888
Hi,
I am trying to use the code below, which I found on this website, but I am
getting an error at " Set objMessage = objSession.Outbox.Messages.Add". This
is about the fourth different code I've tried to have Word email the active
document as an attachment. I've managed (with help) to get it working in
Excel. Why can't they work the same? Any ideas as to my error message?
I am using Windows XP.
Thanks for any help.
Georgie
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 = ""
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 Example"
Set objSession = CreateObject("mapi.session")
objSession.Logon profileName:=sProfile
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = InputBox(sSubjPrmpt, sMsgTitle)
objMessage.Text = InputBox(sTextPrmpt, sMsgTitle)
Set objRecipient = objMessage.Recipients.Add
objRecipient.Name = InputBox(sEmailPrmpt, sMsgTitle)
objRecipient.Resolve
objMessage.Send showDialog:=True
MsgBox "Message sent successfully!"
objSession.Logoff
End Sub
I am trying to use the code below, which I found on this website, but I am
getting an error at " Set objMessage = objSession.Outbox.Messages.Add". This
is about the fourth different code I've tried to have Word email the active
document as an attachment. I've managed (with help) to get it working in
Excel. Why can't they work the same? Any ideas as to my error message?
I am using Windows XP.
Thanks for any help.
Georgie
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 = ""
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 Example"
Set objSession = CreateObject("mapi.session")
objSession.Logon profileName:=sProfile
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = InputBox(sSubjPrmpt, sMsgTitle)
objMessage.Text = InputBox(sTextPrmpt, sMsgTitle)
Set objRecipient = objMessage.Recipients.Add
objRecipient.Name = InputBox(sEmailPrmpt, sMsgTitle)
objRecipient.Resolve
objMessage.Send showDialog:=True
MsgBox "Message sent successfully!"
objSession.Logoff
End Sub