Solved

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

Posted on 2010-08-24
3
441 Views
Last Modified: 2013-11-30
Helllo

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 = www.authsmtp.com
0
Comment
Question by:Websnaky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 33509491
0
 
LVL 7

Expert Comment

by:gnegrota
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 = "me@mycompany.com"
   mail.From = "you@yourcompany.com"
   mail.Subject = "this is a test email."
   mail.Body = "Some text goes here"
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here") 'set your username here
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret") 'set your password here
   SmtpMail.SmtpServer = "mail.mycompany.com" 'your real server goes here
   SmtpMail.Send(mail)
End Sub 'Page_Load

Open in new window

0
 
LVL 3

Accepted Solution

by:
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 = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword"


        '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
      .Update
       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")
    txtTo.SetFocus
Else
    For i = 1 To CInt(txtNumber)
          .Send
    Next
    a = MsgBox("Your Message has been sent", vbInformation, "Message Sent")
End If




txtTo = ""
txtSubject = ""
txtMessage = ""
    End With
    
Errorhandler:
     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

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

718 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