Home
Buy Now
Products
Downloads
Support
Resellers
Contact
Site Map
Home
Buy Now
Download
Support
Home
Purchase
Upgrade
Products
Downloads
Support
Samples
KB
Forum
Newsletter
Customers
Current List
Comments
Resellers
Jobs
Contact Us
VB Sample
ID:
1231
Product:
EasyMail .Net Edition
Description:
Send a message with an attachment - SMTP Assembly
Cut and paste.
The following sample code can be pasted into your application.
Imports Quiksoft.EasyMail.SMTP Module SampleModule Sub Main() Dim msgObj As New EmailMessage() Dim smtpObj As New SMTP() msgObj.Subject= "Subject" 'Add a normal recipient msgObj.Recipients.Add("jdoe@domain.com", "John Doe", RecipientType.To) 'Specify the sender msgObj.From.Email= "bobj@domain.com" msgObj.From.Name= "Bob Johnson" 'Set message body msgObj.BodyParts.Add("Message body.") 'Add attachment msgObj.Attachments.Add("c:\attachment.txt") 'Set mail server smtpObj.SMTPServers.Add("mail.domain.com") Try 'Send the message smtpObj.Send(msgObj) 'Catch exception errors Catch LicenseExcep As LicenseException MessageBox.Show("License key error: " + LicenseExcep.Message) Exit Sub Catch FileIOExcep As FileIOException MessageBox.Show("File IO error: " + FileIOExcep.Message) Exit Sub Catch SMTPAuthExcep As SMTPAuthenticationException MessageBox.Show("SMTP Authentication error: " + SMTPAuthExcep.Message) Exit Sub Catch SMTPConnectExcep As SMTPConnectionException MessageBox.Show("Connection error: " + SMTPConnectExcep.Message) Exit Sub Catch SMTPProtocolExcep As SMTPProtocolException MessageBox.Show("SMTP protocol error: " + SMTPProtocolExcep.Message) Exit Sub End Try MessageBox.Show("Message sent.") End Sub End Module
Did you find this sample useful?
Yes
No
Back to Search Page...
©2013 Quiksoft Corporation. All rights reserved.
Terms of Use
,
Privacy Statement
,
Trademarks