EuropeID Help Center

Domain search
Site search
WHOIS
Browse through 450+ domains across the globe
Search all pages on the site
TLDs News FAQ
Enter domain name to check WHOIS database
benefits of using domain optimisation

Customer Support Information

Sending mail to SMTP Relay with Authentication - How to send e-mails with SMTP Auth? .NET example

How to send e-mails with SMTP Auth? .NET example

Below you can find fully working implementation of the method, which you can use to send mails.

Simply change the property values i.e. “user@domain.tld” to the email address you want to send from, provide your password, and define the recipient (string to).

You may notice, that other code samples doesn’t include the password field, but it’s absolutely necessary to send email through the safe connection.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;

namespace Email
{
    class Program
    {
        static void Main(string[] args)
        {
            string SMTPhost = "mail.web-solutions.dk";
            int SMTPport = 465;

            string from = "user@domain.tld";
            string password = "password";
            string to = "user2@domain.tld";
            string subject = "";
            string body = @"";

            MailMessage message = new MailMessage(from, to, subject, body);
          
            SmtpClient client = new SmtpClient(SMTPhost, SMTPport);
            client.Credentials = new System.Net.NetworkCredential(from, password);

            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught: {0}",
                      ex.ToString());
            }
        }
    }
}

Back to Frequently Asked Questions

Please wait...