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

Send Email with Attachment using MAPI

Posted on 2004-08-18
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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 64
Automatic Email Reminder 4 58
checkbox to hide entire section 10 42
Inserting a datasheet query into the body of an email using VBA? 4 20
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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