Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using mapi mail send how do you add an attachment 1

Status
Not open for further replies.

randy4126

Programmer
Jun 2, 2001
62
US
How would you add an attachment to an email using mapi mail with outlook?
 
...
Set myOlApp = CreateObject("Outlook.Application")
Set out = myOlApp.CreateObject("Outlook.Application")
Set mapi = out.GetNamespace("MAPI")
Set male = out.CreateItem(0)
male.Recipients.Add ("blabla@blabla.net")
male.Subject = "ThisIsAMail"
male.Body = "ThisIsMyMail'sBody"
male.Attachments.Add ("C:\temp\94.tmp")
male.Send
...

ide
B-)
 
On the script player i am using it wont let me do it that way here is a sample of my code that works but i dont know how to attach the email

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 = "Time Warner"

sMsgTitle = "Mapi Macro Example"

Set objSession = CreateObject("mapi.session")

objSession.Logon profileName:=sProfile

Set objMessage = objSession.Outbox.Messages.Add

objMessage.Subject = Subject
objMessage.Text = MessageBody

Set objRecipient = objMessage.Recipients.Add

objRecipient.Name = EmailAddress
objRecipient.Resolve

objMessage.Send showDialog:=False
MsgBox "Message sent successfully!"

objSession.Logoff
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top