How To Send Email To SMTP Server (VB6) - Acc Automation
Có thể bạn quan tâm
Simple mail transfer protocol (SMTP) is the email protocol for sending information. We can use this ability to email from our data logged from the PLC. Faults or errors the PLC detects can be emailed to individuals for correction. Shift reports on productivity can be automatically emailed to recipients.
Note: Google is removing “Less Secured Apps” in the mail app. (Gmail). If you are using this to send email from your controller, you must enable 2-step verification. This will allow you to generate an “App Password” for your controller or program. Gmail Less Secure App Access – App Passwords
Send Email to SMTP Server
We will use visual basic 6 (VB6) to email the SMTP Google Gmail server. Using this method, we can use HTML code to format our messages. Attachments can also be added to the email message. In this example, I have added the ACC icon file.
Add Microsoft CDO for Windows 2000 Library
The first step is to add a reference to Microsoft CDO for Windows 2000 Library. Project -> References 
Make a simple form:
This will have one command button on it labeled “Send Mail”
The code for the command button will be as follows: Private Sub Command1_Click() Call SendEmail End Sub
Add the following Sub SendEmail code to the project : ‘Sample code used to send emails from any SMPT server using CDO in Visual Basic 6.0. ‘Added a reference to the project by navigating to Project -> references and adding Microsoft CDO for windows 2000 Library. Sub SendEmail() On Error Resume Next ‘ Set up error checking Set cdoMsg = CreateObject(“CDO.Message”) Set cdoConf = CreateObject(“CDO.Configuration”) Set cdoFields = cdoConf.Fields ‘ Send one copy with Google SMTP server (with authentication) schema = “http://schemas.microsoft.com/cdo/configuration/” cdoFields.Item(schema & “sendusing”) = 2 cdoFields.Item(schema & “smtpserver”) = “smtp.gmail.com” cdoFields.Item(schema & “smtpserverport”) = 465 cdoFields.Item(schema & “smtpauthenticate”) = 1 cdoFields.Item(schema & “sendusername”) = “[email protected]” cdoFields.Item(schema & “sendpassword”) = “password” cdoFields.Item(schema & “smtpusessl”) = 1 cdoFields.Update With cdoMsg .To = “[email protected]” .From = “[email protected]” .Subject = “Send email to Gmail” ‘ Body of the message can be any HTML code .HTMLBody = “Test message using CDO in vb6 to Gmail smtp” ‘ Add any attachments to the message .AddAttachment “c:\AccDo.ico” Set.Configuration = cdoConf ‘ Send the message .Send End With ‘Check for errors and display message If Err.Number = 0 Then MsgBox “Email Send Successfully,” “Email” Else MsgBox “Email Error” & Err.Number, “Email” End If Set cdoMsg = Nothing Set cdoConf = Nothing Set cdoFields = Nothing End Sub
Running the Program Send Email to SMTP Server
When you run the program, you will get one of the following messages depending on whether the email was correctly sent.

Here is the message that arrives at the recipient: 
A simple mail transfer protocol is an easy way to share information from the PLC data collected. You can download the following VB6 sample code here.
Watch on YouTube: How to Send Email to SMTP Server If you have any questions or need further information, please get in touch with me. Thank you, Garry
If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not challenging to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimals, Hexadecimal, ASCII, and Floating Points.
To get this free article, subscribe to my free email newsletter.
First Name: Last Name: Email address:
Leave this field empty if you're human: Use the information to inform other people how numbering systems work. Sign up now.
The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.
Từ khóa » Visual Basic 6 Send Email With Attachment
-
VB6 - Send Email With Attachment - AdminSystem Software Limited
-
Send Email With Attachment In VB 6.0 - AdminSystem Software Limited
-
Thread: Vb6 - Send Email With Attachment Using Smtp - VBForums
-
Visual Basic 6.0 Send Email With Attachments - Chilkat Examples
-
Using Vb6 To Send Email With Attachment - P2p .wrox .coM - Wiley
-
How To Send An Email With Attachment In VB6? - CodeGuru Forums
-
VBScript: Send Email With Attachment - United States (English)
-
Email Application With Attachment Of File - YouTube
-
Send Email With Attachments In Visual Basic 2010 - YouTube
-
Send Mail In Visual Basic 6.0 Windows Application - CodeProject
-
Sending EMail From Visual Basic 6.0 - Spiceworks Community
-
How To Send Mail Using CDO Visual Basic - Sharing
-
Send Email With An Attachment By Smtp - Visual Basic 4 / 5 / 6
-
Visual Basic, Email Object In VB 6??