Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 17,729 times

Downloads

Related Categories

MAPI Emailer

alexreg

Simply add a buttons named cmdExit and cmdSend, text boxes named EmailAddress, Subject, MessageText, and a MAPIMessages object (available via Project|Components). Then add the following code. There is a project demonstrating this in the download above.

Function SendMessage(EmailAddress As String, Subject As String, MessageText As String)
On Error GoTo mailerr:
MAPISession1.SignOn
If MAPISession1.SessionID <> 0 Then
    With MAPIMessages1
        .SessionID = MAPISession1.SessionID
        .Compose
        .RecipAddress = EmailAddress
        .MsgSubject = Subject
        .MsgNoteText = MessageText
        .Send False
    End With
   
    MsgBox "Message Sent.", vbInformation
End If
Exit Function
mailerr:
MsgBox "Error: " & Err.Description, vbCritical
End Function
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSend_Click()
If txtAddress.Text <> vbNullString Then
    SendMessage txtAddress.Text, txtSubject.Text, txtMessage.Text
Else
    MsgBox "You have not entered the email address to send the message to.", vbInformation
End If
End Sub

Currently programs in VB, QBasic, ASP, PHP, SQL, HTML, CSS, VBScript and some Java/JavaScript. Learning VB.NET.

Comments

  • Re: [2458] MAPI Emailer

    Posted by evanscolin on 01 Dec 2006

    Hi, this is probably a miss on my part but when I use the example you've given I get and error linked to MAPISession1 - varibale not defined, I'm obviously missing a component, I've added the MAPIMess...

  • email send locks up

    Posted by lunchbox on 22 Feb 2004

    Hi

    I am trying to use the simple email method in VB6 using a MAPIMessage object in Win98se.

    Here is the start of the code:

    Function SendMessage(EmailAddress As String, Subject As String, Mes...