Send Email with Attachment using MAPI

Posted on 2004-08-18
Medium Priority
Last Modified: 2012-05-05
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.
Question by:Shidartha
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 28

Expert Comment

ID: 11829563
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
End With

Author Comment

ID: 11829976
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
mpMessage.SessionID = mpSession.SessionID
'Prepara e envia a mensagem
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)
'Termina a seção
Exit Sub

    MsgBox Error$, vbCritical, "Critical Error: " & Str(Err)
LVL 70

Expert Comment

by:Éric Moreau
ID: 11830167
Do you have to use MAPI or could you use a SMTP mailer?

See http://www.freevbcode.com/ShowCode.asp?ID=109

Author Comment

ID: 11832907
I discover the solution to my problem.

i must use:

Thanks all u guys.

Accepted Solution

modulo earned 0 total points
ID: 12542532
PAQed, with points refunded (500)

Community Support Moderator

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question