Hi Folks Good Day all
I have created a web service(Windows server 2018 R2 enterprise) where I send mail using the code
public void SendMail(string f, string t, string subject, string body)
{
System.Web.Mail.MailMessage Message = new System.Web.Mail.MailMessage();
Message.From = f;
Message.To = t;
Message.Subject = subject;
Message.Body = body;
Message.BodyFormat = MailFormat.Html;
System.Web.Mail.SmtpMail.SmtpServer = "smtp.Company.com";
System.Web.Mail.SmtpMail.Send(Message);
}
When mail triggered from Address is like "Suresh Kukka" (display name)
if I Use the same code hosting same web service (Windows Server 2016 Standard) I am getting mail from address like "suresh.kukka@company.com"
I have used new code like below (web service hosted in Windows Server 2016 Standard)
public void SendMail(string f, string t, string subject, string body){System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage();
string[] name = f.Split('@');
string[] mainname = name[0].Split('.');
string DisplayName = mainname[0] + " " + mainname[1];
TextInfo _textinfo = new CultureInfo("en-US", false).TextInfo;
DisplayName = _textinfo.ToTitleCase(DisplayName);
// Message.From = f;
MailAddress address = new MailAddress(f, DisplayName);
Message.From = address;
Message.To.Add(t);
Message.Subject = subject;
Message.Body = body;
Message.IsBodyHtml = true;
SmtpClient objclint = new SmtpClient();
objclint.EnableSsl = true;
objclint.Port = 25;
objclint.Host = "smtp.company.com";
objclint.Send(Message);
Message.Dispose();
}
here I am getting mail From address like "Suresh Kukka<suresh.kukka@company.com>" but i want the from addrees like "Suresh Kukka" only.. can anybody help me on this