Link to home
Start Free TrialLog in
Avatar of Shidartha
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.
Avatar of vinnyd79
vinnyd79

Are you using MAPI controls? If so,have you tried:

With frmMain.MAPIMessages1
    .MsgIndex = -1
    .RecipDisplayName = "someone@somewhere.com"
    .MsgSubject = "Subject line"
    .AttachmentPathName = "C:\somefile.jpg"
    .MsgNoteText = "Body of Msg"
    .SessionID = frmMain.MAPISession1.SessionID
    .Send
End With
Avatar of Shidartha

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.AttachmentPathName = "c:\foto1.jpg"
mpMessage.AttachmentPosition = Len(mpMessage.MsgNoteText)
mpMessage.Send
'Termina a seção
mpSession.SignOff
Exit Sub

TrataErro:
    MsgBox Error$, vbCritical, "Critical Error: " & Str(Err)
    End
Avatar of Éric Moreau
Do you have to use MAPI or could you use a SMTP mailer?

See http://www.freevbcode.com/ShowCode.asp?ID=109
I discover the solution to my problem.

On
mpMessage.AttachmentName="foto"
i must use:
mpMessage:AttachmentName="foto.jpg"

Thanks all u guys.
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial