Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used the below code to show display name, but now its displaying as example[example@abc.com] in outlook. Is it possible to show only display name in From address


MailMessage mail = new MailMessage();
mail.To.Add(new MailAddress(mailPropObj.ToAddress.ToString()));  
mail.From = new MailAddress(example@abc.com,"example");


Does anyone have a solution?
Posted
Updated 18-Apr-18 19:27pm
v4
Comments
sencsk 3-Jan-20 7:39am    
Hi, I've tried with the same code. but I'm getting output like below
abcs.c <test@abc.in>

The sender's name always comes along with the display name. Can anybody help to resolve this. how can i remove/hide the sender name <test@abc.in>

Use symbols < > along with email & name like below
C#
System.Net.Mail.MailMessage Mail = new System.Net.Mail.MailMessage("example<example@abc.com>", "a@a.com", Subject, Message);
 
Share this answer
 
Comments
Hiren solanki 28-Oct-10 7:27am    
Nicely spotted , Raja the Thatraja.
Sandeep Mewara 28-Oct-10 13:01pm    
Comment from OP:hi raja,

I tried this also but its showing the same output.

thx.
use this for this line. don't add net.mail namespace

myMail.From = new System.Net.Mail.MailAddress(From1, EmailFromName).ToString();
 
Share this answer
 
v2
Comments
Kats2512 19-Apr-18 2:54am    
question that was asked answered 8 years ago!!!!
Nelek 26-Apr-18 10:45am    
as long as it is a valid answer. it is not a problem, that the question is old. In 8 years technology has changed, maybe the good answer that was accepted is not valid anymore

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900