SMTP (System.Web.Mail??)

  • Thread starter Thread starter Mustafa Rabie
  • Start date Start date
M

Mustafa Rabie

Hi,

I am using the Smtp component that comes with the .Net framework. I wanted
to know how can I set the Diaplay name of the user when sendind the message?
e.g. "Mustafa" <[email protected]>
when i send a message i revice the email in the From but i want to diaplay
both the Display name and the email address.

Thanks
Mustafa
 
Hi Ross,

i tried that again and nuthing, the display name is not showing

i used
cmailMessage.To = "Mustafa Rabie <[email protected]>" //where cmailMessage
is the message class

can you check if that's the same syntax u used?

thanks

Ross Jones said:
Hi,

I'm fairly sure I've had success using

Ross Jones < (e-mail address removed) >

HTH.


Mustafa Rabie said:
i tried that but no luck

any ideas?

thanks
see
it
in web-mail) "Bill Gates [[email protected]].
jason.

:

Hi,

I am using the Smtp component that comes with the .Net framework. I wanted
to know how can I set the Diaplay name of the user when sendind the message?
e.g. "Mustafa" <[email protected]>
when i send a message i revice the email in the From but i want to diaplay
both the Display name and the email address.

Thanks
Mustafa
 
Mustafa,

Here's the code I used to send the message..

class MailTest
{
[STAThread]
static void Main(string[] args)
{
MailMessage msg = new MailMessage();
msg.From = "Ross Jones <ross@mydomain>";
msg.To = "Ross Jones <ross@mydomain>";
msg.Subject = "Email test";
msg.BodyFormat = MailFormat.Text;
msg.Body = "This is my email test";
SmtpMail.SmtpServer = "customermail.easily.co.uk";
SmtpMail.Send( msg );
Console.WriteLine( " Message sent " );
}
}

The email comes through in Outlook as
Ross Jones [ross@mydomain]

The actual header looks like
From: "Ross Jones" <[email protected]>

If you like I could try out your code on my mail server to see what it does,
if you could trim the code down to the bare minimum.

Ross.

Mustafa Rabie said:
Hi Ross,

i tried that again and nuthing, the display name is not showing

i used
cmailMessage.To = "Mustafa Rabie <[email protected]>" //where cmailMessage
is the message class

can you check if that's the same syntax u used?

thanks

Ross Jones said:
Hi,

I'm fairly sure I've had success using

Ross Jones < (e-mail address removed) >

HTH.


Mustafa Rabie said:
i tried that but no luck

any ideas?

thanks

I dont remember the exact format but it is something like this (you
see
it
in web-mail) "Bill Gates [[email protected]].

jason.

:

Hi,

I am using the Smtp component that comes with the .Net framework. I
wanted
to know how can I set the Diaplay name of the user when sendind the
message?
e.g. "Mustafa" <[email protected]>
when i send a message i revice the email in the From but i want to
diaplay
both the Display name and the email address.

Thanks
Mustafa
 
hi Ross,

Thanks for the code, i tried it out and still i am not getting except the
email?
here's my code that sends the message. If you want me to send you the whole
app, it's very small btw tell me where to email you the zip file.

Thanks a lot for your help really appreciate it :)
public bool SendMessage(string szTO, string szCC, string szBCC, string
szFrom, string szSubject, string szBody)

{

bool fRet = false;

if ((szTO != "") && (szFrom != ""))

{

cmailMsg.To = "Mustafa Rabie <mrabie@mrabie-w2k3>";

cmailMsg.Cc = szCC;

cmailMsg.Bcc = szBCC;

cmailMsg.From = szFrom;

cmailMsg.Subject = szSubject;

cmailMsg.Body = szBody;

try

{

SmtpMail.SmtpServer = "localhost";
//System.Configuration.ConfigurationSettings.AppSettings["pop3Host"];

SmtpMail.Send(cmailMsg);

fRet = true;

}

catch(Exception exp)

{

fRet = false;

}

}

else

{

fRet = false;

}

return fRet;

}

Ross Jones said:
Mustafa,

Here's the code I used to send the message..

class MailTest
{
[STAThread]
static void Main(string[] args)
{
MailMessage msg = new MailMessage();
msg.From = "Ross Jones <ross@mydomain>";
msg.To = "Ross Jones <ross@mydomain>";
msg.Subject = "Email test";
msg.BodyFormat = MailFormat.Text;
msg.Body = "This is my email test";
SmtpMail.SmtpServer = "customermail.easily.co.uk";
SmtpMail.Send( msg );
Console.WriteLine( " Message sent " );
}
}

The email comes through in Outlook as
Ross Jones [ross@mydomain]

The actual header looks like
From: "Ross Jones" <[email protected]>

If you like I could try out your code on my mail server to see what it does,
if you could trim the code down to the bare minimum.

Ross.

Mustafa Rabie said:
Hi Ross,

i tried that again and nuthing, the display name is not showing

i used
cmailMessage.To = "Mustafa Rabie <[email protected]>" //where cmailMessage
is the message class

can you check if that's the same syntax u used?

thanks

Ross Jones said:
Hi,

I'm fairly sure I've had success using

Ross Jones < (e-mail address removed) >

HTH.


i tried that but no luck

any ideas?

thanks

I dont remember the exact format but it is something like this
(you
see
it
in web-mail) "Bill Gates [[email protected]].

jason.

:

Hi,

I am using the Smtp component that comes with the .Net
framework.
 
Back
Top