Solved

Send Email with Attachment using MAPI

Posted on 2004-08-18
7
367 Views
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.
0
Comment
Question by:Shidartha
7 Comments
 
LVL 28

Expert Comment

by:vinnyd79
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
    .Send
End With
0
 

Author Comment

by:Shidartha
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
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
0
 
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
0
 

Author Comment

by:Shidartha
ID: 11832907
I discover the solution to my problem.

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

Thanks all u guys.
0
 

Accepted Solution

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

modulo
Community Support Moderator
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

776 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