-
4
Answers
-
Last Activity:
long time ago,
sherifalfy
Your question has been submitted and is awaiting moderation.
Thank you for reporting this content, moderators have been notified of your submission.
string smtpServer = "mail.occtbangalore.org";string smtpAuthentication = (string)Globals.HostSettings["SMTPAuthentication"];string smtpUsername = (string)Globals.HostSettings["SMTPUsername"]; string smtpPassword = (string)Globals.HostSettings["SMTPPassword"];
MailMessage mail = new MailMessage();
mail.From = new MailAddress("info@myhost.c);
mail.To.Add(txtEmail.Text.Trim());
mail.Subject = "OCCT BANGALORE";
string html = "";
AlternateView av2 = AlternateView.CreateAlternateViewFromString(html, null, "text/html");
string logoFile = MapPath(PortalSettings.HomeDirectory + PortalSettings.LogoFile);
if (File.Exists(logoFile))
{
LinkedResource linkedResource = new LinkedResource(logoFile);
linkedResource.ContentId = "Logo";
linkedResource.ContentType.Name = logoFile;
linkedResource.ContentType.MediaType = "image/jpeg";
av2.LinkedResources.Add(linkedResource);
}
mail.AlternateViews.Add(av2);
SmtpClient emailClient = new SmtpClient(smtpServer);
if (smtpAuthentication == "1")
{
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(smtpUsername, smtpPassword);
emailClient.UseDefaultCredentials = false;
emailClient.Credentials = SMTPUserInfo;
}
emailClient.Send(mail);
But I am getting below error where i did mistake
**The SMTP server requires a secure connection or the client was not authenticated. The server response was: SMTP authentication is required.**
Thanks & Regards
Gopinath