PDA

Click to See Complete Forum and Search --> : bets way to send email from vb6


Mark Sreeves
May 2nd, 2000, 07:42 PM
This just uses the Active Messaging: Olemsg32.dll

Private Sub EmailMessage()



Dim oSession As MAPI.Session
Dim oMessage As MAPI.message
Dim oRecipient As MAPI.Recipient


Set oSession = CreateObject("MAPI.Session")

oSession.Logon '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 " & App.Title
.Text = "This is a test message"
.Attachments.Add "c:\yourFile.txt"

Set oRecipient = oMessage.Recipients.Add
oRecipient.Name = "someone@somewhere"
oRecipient.Resolve



.Update


.Send
End With
oSession.Logoff
Set oSession = Nothing
Set oMessage = Nothing
Set oRecipient = Nothing



End Sub



[Edited by Mark Sreeves on 05-12-2000 at 12:39 PM]

Mark Sreeves
May 11th, 2000, 06:43 PM
WILL anyone using this code please remove my email address from it as I keep getting "Test Messages"!


(I included my email add in oRecipient.Name = ...)