Shidartha
asked on
Send Email with Attachment using MAPI
Well, i wanna send some emails with attachment, like pics for example. But all file types that i tried are converted to .dat files. So Me.jpg became Me.dat when i receive the email. I tryed all 3 attachmentype properties (mapDATA, mapEOLE, mapSOLE), nothing happens. Please, how can i send doc, jpeg, gif, exe files using MAPI? By the way, im using Visual Basic 6, Windows XP and Outlook Express. Thanks.
ASKER
Didnt work :(
I'm using this code:
On Error GoTo TrataErro
'Inicializa uma seção MAPI
mpSession.UserName = "budd"
mpSession.Password = "budd"
mpSession.DownLoadMail = False
mpSession.LogonUI = False
mpSession.SignOn
mpMessage.SessionID = mpSession.SessionID
'Prepara e envia a mensagem
mpMessage.Compose
mpMessage.MsgIndex = -1
mpMessage.RecipAddress = "ssrosa@uai.com.br"
mpMessage.RecipDisplayName = "Sr. Papai"
mpMessage.MsgSubject = "Teste de Email"
mpMessage.MsgNoteText = Text1.Text
'Inclui o anexo
'mpMessage.AttachmentType = mapData
mpMessage.AttachmentName = "foto"
mpMessage.AttachmentPathNa me = "c:\foto1.jpg"
mpMessage.AttachmentPositi on = Len(mpMessage.MsgNoteText)
mpMessage.Send
'Termina a seção
mpSession.SignOff
Exit Sub
TrataErro:
MsgBox Error$, vbCritical, "Critical Error: " & Str(Err)
End
I'm using this code:
On Error GoTo TrataErro
'Inicializa uma seção MAPI
mpSession.UserName = "budd"
mpSession.Password = "budd"
mpSession.DownLoadMail = False
mpSession.LogonUI = False
mpSession.SignOn
mpMessage.SessionID = mpSession.SessionID
'Prepara e envia a mensagem
mpMessage.Compose
mpMessage.MsgIndex = -1
mpMessage.RecipAddress = "ssrosa@uai.com.br"
mpMessage.RecipDisplayName
mpMessage.MsgSubject = "Teste de Email"
mpMessage.MsgNoteText = Text1.Text
'Inclui o anexo
'mpMessage.AttachmentType = mapData
mpMessage.AttachmentName = "foto"
mpMessage.AttachmentPathNa
mpMessage.AttachmentPositi
mpMessage.Send
'Termina a seção
mpSession.SignOff
Exit Sub
TrataErro:
MsgBox Error$, vbCritical, "Critical Error: " & Str(Err)
End
Do you have to use MAPI or could you use a SMTP mailer?
See http://www.freevbcode.com/ShowCode.asp?ID=109
See http://www.freevbcode.com/ShowCode.asp?ID=109
ASKER
I discover the solution to my problem.
On
mpMessage.AttachmentName=" foto"
i must use:
mpMessage:AttachmentName=" foto.jpg"
Thanks all u guys.
On
mpMessage.AttachmentName="
i must use:
mpMessage:AttachmentName="
Thanks all u guys.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
With frmMain.MAPIMessages1
.MsgIndex = -1
.RecipDisplayName = "someone@somewhere.com"
.MsgSubject = "Subject line"
.AttachmentPathName = "C:\somefile.jpg"
.MsgNoteText = "Body of Msg"
.SessionID = frmMain.MAPISession1.Sessi
.Send
End With