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?


Reply With Quote