Send mails via Authsmtp using a visual Basic programm (VB6)

Posted on 2010-08-24
Last Modified: 2013-11-30

I am looking for an exemple on how to send an email from a VB6 program using the smtp server 'authsmtp' and without using an email client like Outlook etc
Authsmtp website =
Question by:Websnaky
LVL 69

Expert Comment

by:Éric Moreau
ID: 33509491

Expert Comment

ID: 33509615
example code VB.NET attached
You MUST use VB6 ?!
Private Sub Page_Load(sender As Object, e As System.EventArgs)
   Dim mail As New MailMessage()
   mail.To = ""
   mail.From = ""
   mail.Subject = "this is a test email."
   mail.Body = "Some text goes here"
   mail.Fields.Add("", "1") 'basic authentication
   mail.Fields.Add("", "my_username_here") 'set your username here
   mail.Fields.Add("", "super_secret") 'set your password here
   SmtpMail.SmtpServer = "" 'your real server goes here
End Sub 'Page_Load

Open in new window


Accepted Solution

DeltaR7 earned 125 total points
ID: 33509685
Here is a full VB6 code
note there might be some fields in you need to rename or delete

Private Sub cmdSend_Click()

Dim a As String

Dim errorBool As Boolean

On eror GoTo Errorhandler

Set m_objCDO = CreateObject("CDO.Message")

Set m_objCDOcon = CreateObject("CDO.Configuration")

Const cdoSendUsingMethod = ""

Const cdoSendUsingPort = 2

Const cdoSMTPServer = ""

Const cdoSMTPServerPort = ""

Const cdoSMTPConnectionTimeout = ""

Const cdoSMTPAuthenticate = ""

Const cdoBasic = 1

Const cdoSendUserName = ""

Const cdoSendPassword = ""

        'Sending email notification

Set Fields = m_objCDOcon.Fields

'Setting up Message parameters

      With Fields

      .Item(cdoSendUsingMethod) = cdoSendUsingPort

      'Replace with your SMTP server

      .Item(cdoSMTPServer) = txtEmailServer.Value

      .Item(cdoSMTPServerPort) = CInt(txtServerport)

      .Item(cdoSMTPConnectionTimeout) = 100

      'Only used if SMTP server requires Authentication

      If chkLogin = -1 Then

      .Item(cdoSMTPAuthenticate) = cdoBasic

      .Item(cdoSendUserName) = txtLogin

      .Item(cdoSendPassword) = txtPassword

      End If


       End With


       'Passing parameters to message object

       Set m_objCDO.Configuration = m_objCDOcon


    With m_objCDO

        'Replace with email you wish the message to be sent to

        .To = txtTo

        If Not (txtCC.Value = "") Then

        .CC = txtCC

        End If

        If Not (txtBCC.Value = "") Then

        .BCC = txtBCC

        End If

        'Replace with email you wish the message to be from

        .From = txtFrom


        ' Attachment using known static physical path

        '.AddAttachment "c:\Multiping.xls"

        '.AddAttachment Server.MapPath("images/asp101-100x30.gif")

        ' Attachment added directly from a URL

                'Replace with subject


        .Subject = txtSubject


        'Replace with information you want to be sent

        If Not (txtMessage.Value = "") Then

        .HTMLBody = txtMessage

        End If

If txtTo.Value = "" Or IsNull(txtTo) Then

    a = MsgBox("Please fill out a recipient", vbInformation, "To")



    For i = 1 To CInt(txtNumber)



    a = MsgBox("Your Message has been sent", vbInformation, "Message Sent")

End If

txtTo = ""

txtSubject = ""

txtMessage = ""

    End With



     If Not (Err.Number = 0) Then

   a = MsgBox("An error has occured: " & Err.Description, vbCritical, "Error")

   Exit Sub

   End If


End Sub

Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
OWA address for domain 6 37
Redacting a row in Excel based on a term. 17 53
Not showing page correctly 3 29
Not showing JavaScript in the list 5 35
Hello Friends, My friends and relatives always ask me how to delete all the various types of emails at once in our g-mail  or windows live account.  So I researched this topic to find a unique solution to this query.  Here it is for those who do …
There was an incident about the POP3 issue for the double read receipts and delivery receipts in Exchange 2013.  There was huge research been done and found solution for the duplicate mails. Especially when the user gets  duplicate mails.
A short film showing how OnPage and Connectwise integration works.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now