Knowledgebase: outmail
How do I set up outbound SMTP using the .Net SmtpClient Class?

Problem:

How do I set up outbound SMTP using the .Net SmtpClient Class?
How do I set up outbound SMTP using .Net?
How do I use outMail in .NET?

Solution:

The following example of code assumes you have already got a fully functional webserver and the .Net Framework Installed

The below example of code shows you have to use outMail as the outgoing SMTP relay using the SmtpClient Class in the .Net Framework

Example VB.NET code

' Create the Mail Message
Dim Mail As New MailMessage

' Set the address information
Mail.From = New MailAddress("myaddress@example.com") 
Mail.To.Add("sendingaddress@example.com")

' Set the content of the email
Mail.Subject = "test email"
Mail.Body = "This is an email!"

' Send the message
Dim SMTP As New SmtpClient("mxXXXXXX.smtp-engine.com")
SMTP.EnableSsl = False
SMTP.Credentials = New System.Net.NetworkCredential("outmail-username", "outmail-password")
SMTP.Port = 25
SMTP.Send(Mail)

Example VB.NET code (Safer Error trapping method)

' Create the Mail Message
Using Mail As New MailMessage

	' Set the address information
	Mail.From = New MailAddress("myaddress@example.com") 
	Mail.To.Add("sendingaddress@example.com")

	' Set the content of the email
	Mail.Subject = "test email"
	Mail.Body = "This is an email!"

	' Send the message
	Using SMTP As New SmtpClient("mxXXXXXX.smtp-engine.com")
		SMTP.EnableSsl = False
		SMTP.Credentials = New System.Net.NetworkCredential("outmail-username", "outmail-password")
		SMTP.Port = 25
		SMTP.Send(Mail)
	End Using
End Using

Example C# code

 
// Create the Mail Message MailMessage 
mail = new MailMessage();   

// Set the address information 
mail.From = new MailAddress("myaddress@example.com");  
mail.To.Add("sendingaddress@example.com");  

// Set the content of the email 
mail.Subject = "test email"; 
mail.Body = "This is an email!";  

// Send the message 
SmtpClient smtp = new SmtpClient("mxXXXXXX.smtp-engine.com"); 
smtp.EnableSsl = False; 
smtp.Credentials = New NetworkCredential("outmail-username", "outmail-password"); 
smtp.Port = 25; smtp.Send(Mail); 

Summary of server details

Outgoing server

mxXXXXXX.smtp-engine.com

As provided in your signup email.

Outgoing server protocol

SMTP

Outgoing server port

25, 587, 2525 or 8025

Authentication Type

Basic Authentication

Username

As provided

Password

As provided

 

(6 vote(s))
Helpful
Not helpful





Disclaimer
The Origin of this information may be internal or external to Prolateral Consulting Ltd. Prolateral makes all reasonable efforts to verify this information. However, the information provided in this document is for your information only. Prolateral makes no explicit or implied claims to the validity of this information. Any trademarks referenced in this document are the property of their respective owners.