-
I use the following codes to send email and attachments
(Courtesy of MarkSleeve)
Dim oSession As MAPI.Session
Dim oMessage As MAPI.Message
Dim oRecipient As MAPI.Recipient
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "Microsoft Outlook" 'this will promt for a profile. This can be avoided by including the profile name
Set oMessage = oSession.Outbox.Messages.Add
With oMessage
.Subject = "Email From Chong For Testing"
.Text = "This is a test message from kmchong"
.Attachments.Add "c:\temp\screencam.bmp"
Set oRecipient = oMessage.Recipients.Add
oRecipient.Name = "[email protected]"
oRecipient.Resolve
.Update
.Send
End With
oSession.Logoff
Set oSession = Nothing
Set oMessage = Nothing
Set oRecipient = Nothing
It works to send the subject and text attachment. But if I send bitmap attachment, the received file is blank (when I use paintbush to view)
Do anybody can tell me WHY?
-
Hmm... it didn't seem to want to work for me with bitmaps either!
You could ytr using the Outlook object libriary instead as it seems a bit more robust.
-
..or you could download BuzMail from http://www.PlanetSourceCode.com/vb - just search for "BuzMail". This is my MAPI 'object' that allows you to send e-mails with or without attachments without having to resort to the horrible MS MAPI commands.