Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29755

SMTP relay - send email from console application

$
0
0

Is it possible to send email from a server that uses smtp-relay through a .net application.

I'm using app.config to get the actual values ex server IP, and the fromadress that the email should use.

According to the IT-technician the username and password to authorize should not be needed because it uses smtp-relay. The computer that are going to send the email is on the smtp-servers list of valid computers.

Can this actually work, don't I need to specify the username/pwd?

try{    MailMessage mail = new MailMessage();    SmtpClient SmtpServer = new SmtpClient(_smtpserver);    mail.From = new MailAddress(_fromAdress);    mail.To.Add(_toAdress);    mail.Subject = _subject;    mail.Body = _body;    mail.Priority = MailPriority.High;    SmtpServer.Port = Convert.ToInt32(_port);    SmtpServer.Credentials = new System.Net.NetworkCredential(_authUsername, _authPassword);    SmtpServer.EnableSsl = true;    SmtpServer.Send(mail);}catch (Exception ex){    Console.WriteLine(ex.ToString());}

Viewing all articles
Browse latest Browse all 29755

Trending Articles