Results 1 to 7 of 7

Thread: Sending Email using VB

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2004
    Location
    India
    Posts
    56

    Question Sending Email using VB

    Hi all

    Actually I have some data and I want to send it to some email id
    when user clicks on the command button the data (in fact a string ) should b send to the hard coded email id.

    how can I do it?

    Nahush.

  2. #2
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    Open a project, put following controls.

    TextBox called txtSendTo
    TextBox callled txtSubject
    TextBox called txtMessage
    MAPIMessages called MAPIMessages1
    MAPISession called MAPISession1
    Commandbutton called cmdSend

    -----------------------
    To Add MAPI controls
    -----------------------
    Click on Project Menu -> Components and find Microsoft MAPI Controls and check that box and press OK.

    Now you should have 2 more controls in Toolbox on the left hand side. Just add them to the form.
    -----------------------

    and the following code should do it.


    VB Code:
    1. Private Sub cmdSend_Click()
    2.    If Trim(txtSendTo.Text) = "" Then
    3.        MsgBox "Please enter an email address to send EMail.", vbInformation, MSGBoxTitle
    4.    Else
    5.        MAPISession1.SignOn
    6.        With MAPIMessages1
    7.                .MsgIndex = -1
    8.                .RecipDisplayName = txtSendTo.Text
    9.                .MsgSubject = txtSubject.Text
    10.                .MsgNoteText = txtMessage.Text
    11.                .SessionID = MAPISession1.SessionID
    12.                .Send
    13.        End With
    14.        
    15.        MsgBox "Message sent.", vbInformation, MSGBoxTitle
    16.        MAPISession1.SignOff
    17.    End If
    18. End Sub

    Cheers

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2004
    Location
    India
    Posts
    56

    Update

    the code above requires outlook express

    But can be there any possibility that even if the computer with

    outlook not installed should also send the msg.

    i.e inspite of the outlook (or NE other mail prgm ) the mail should

    be sent to the resipient

    Nahush

  4. #4
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    in that case u might want to look at SMTP stuff. But unfortunately I haven't got any code for that. Sorry.

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Search for SMTP


    Has someone helped you? Then you can Rate their helpful post.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    goto http://www,codehound.com/vb
    in the search box, enter VBSendMail. Click Search (or GO, or what ever the button is).
    Sift through the results, there's plenty of examples on this.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    Registered User
    Join Date
    Jul 2001
    Location
    israel
    Posts
    81
    Hi All!!!

    I M trying to send mail but a need your help.

    i have microsoft outlook with one address and outlook express with another address and when i m sending ,mail it sends with the mail of the microsoft outlook and i want to send the mail with the address in the outlook express .

    what should i do ?

    10x

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width