Results 1 to 6 of 6

Thread: How to send Email through VB ?

  1. #1

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Question

    Hey all...
    Does any1 know how can I send an Email through VB code?
    I mean, I dont wanna use the Shell method for openning the Outlook Express and then I'll have to click on the Send button.

    I wanna send Email, lets say to [email protected] ,
    without openning the Outlook Express, And I wanna be able
    to set all of the Email features, like Subject, Body, Attachment,....

    Any Idea?

  2. #2
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186
    Hi, of course you can do this from VB code, what you must make sure of is, that you need the CDO 1.21 object and for the example I'm giving you the CDONTS Dll, these are automatically installed with win2000, or if you are working on NT they come with Exchange Server.

    code:

    Private Sub cmdSend_Click()

    On Error GoTo Me_Err_Handle

    Dim CDO As CDONTS.NewMail
    Set CDO = CreateObject("CDONTS.NewMail")

    CDO.From = txtFrom
    CDO.To = txtTo
    If Len(Trim(txtCc)) > 0 Then CDO.Cc = txtCc
    If Len(Trim(txtBcc)) > 0 Then CDO.Bcc = txtBcc
    If Len(Trim(txtSubject)) > 0 Then CDO.Subject = txtSubject
    CDO.Body = txtBody
    CDO.BodyFormat = 0
    CDO.AttachFile txtAttachment
    CDO.Send

    Exit Sub

    Me_Err_Handle:

    MsgBox Err.Number & " - " & Err.Description, vbCritical, "Error..."

    End Sub


    Make a form with some text boxes and a send button. You can name the text boxes as the example.

    Good luck,

    André

  3. #3
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Taipei
    Posts
    318

    Arrow

    If I am using Win98 and VB5/VB6, can I use the CDO1.21, if so, where can I download / purchase this?

  4. #4
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186
    Hi, here is some software info:

    To enable client applications to use CDO 1.2.1, install Microsoft Outlook 98. For server applications, install Microsoft Exchange Server version 5.5.

    Note CDO works with Microsoft Outlook, but CDO.DLL is not installed with the Microsoft Outlook 97 setup program.

    If you want to learn more try this link:
    http://msdn.microsoft.com/library/de...aover_34a7.htm

    PS. The code I presented earlier works for CDONTS, coding for CDO 1.21 is slightly different, but you'll find all you need in that link,

    good luck,
    André

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Taipei
    Posts
    318
    How about for users's machine, do they have to install outlook?

  6. #6
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186
    I'm afraid so.

    André

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