Wednesday, January 13, 2010

Send Email using MAPI control on VB6

Here is a simple way to send messages using MAPI control. First add the MAPI component and add the MAPI session and MAPI mail control in your form. Then paste the following code:

Public Function send_mail(sendto As String, subject As String, _
text As String) As Boolean

On Error GoTo ErrHandler
With MAPISession1
.DownLoadMail = False
.LogonUI = True
.SignOn
.NewSession = True
MAPIMessages1.SessionID = .SessionID
End With
With MAPIMessages1
.Compose
.RecipAddress = sendto
.AddressResolveUI = True
.ResolveName
.MsgSubject = subject
.MsgNoteText = text
.Send False
End With
sendmail = True
ErrHandler:
End Function


No comments:

Post a Comment