[RESOLVED]mailmessage from and reply

Hi guys.
Can anyone help me out. Im using mailmessage() . currently the ‘from’ is from my customer support email. Id like the email on the recipient side to show that the email is coming from the ‘customers’ email address and if that message is replied on that it also
goes to the customer.

Thanks in advance

Just set the From property of the message


However I’ll make an assumption that you’re using gmail’s smtp servers to send your email.  If that is the case, don’t, use the smtp server provided by whoever hosts your website as that should be configured to allow you to use any "from" you want (a process
called relaying).

You can add email address to the

message.ReplyToList.Add(new MailAddress{"Someone@somewhere.com"});

or more simply


hi Guys,

Thanks for the response, I’m busy trying it out now – will post back shortly.

Hmm. I have System.Web.Mail.MailMessage mailMessage = new System.Web.Mail.MailMessage();

then…. mailMessage.ReplyToList.Add(new MailAddress{"fun@games.com"});

However I get the error below: - 

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1061: ‘System.Web.Mail.MailMessage’ does not contain a definition for ‘ReplyToList’ and no extension method ‘ReplyToList’ accepting a first argument of type ‘System.Web.Mail.MailMessage’ could be found (are you missing
a using directive or an assembly reference?)

Am I missing an argument or statement.

System.Web.Mail.MailMessage mailMessage = new System.Web.Mail.MailMessage();            
    string smtpServer = "mysmtpservername";
    string smtpusername = "myusername";
    string smtppassword = "mypassword";

    mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
    mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25) ;
    mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", true); 
    mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", smtpusername); 
    mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", smtppassword);
    mailMessage.ReplyToList.Add(new MailAddress{"fun@games.com"});
                mailMessage.To = "recipient";
                mailMessage.From = "hosting server email account";
                mailMessage.Subject = "Subject...";
                mailMessage.Body = "Body ,  "

Use System.Net.Mail. System.Web.Mail was deprecated about 9 years ago when ASP.NET 2 was introduced.


Try this example:

               MailMessage msg = New MailMessage ();
               MailAddress fromAdd = New MailAddress("fromemail@email.com");
               msg.Subject = "Choose Session Members";
               msg.From = fromAdd;
               msg .IsBodyHtml = True;
               msg.Priority = MailPriority.Normal;
               msg .BodyEncoding = Encoding.Default;
               msg.Body = "<center><table><tr><td><h1>Your Message</h1><br/><br/></td></tr>";
               msg.Body = msg.Body + "</table></center>";
               SmtpClient smtpClient = New SmtpClient ("smtp.yourserver.com", "25");
               smtpClient.EnableSsl = True;
               smtpClient.UseDefaultCredentials = False;
               smtpClient.Credentials = New System.Net.NetworkCredential("smtpserver@yourserver.com", "password");
               smtpClient .DeliveryMethod = SmtpDeliveryMethod.Network;
        Catch (Exception ex){
            Label1.Text  = ex.ToString();

Hi Mike/Phil,

I’m busy reading up on System.Net.Mail = and making a few code changes to accommodate it.

Will post back in a bit.


Hi Mike/Phil,

Thank so much for assisting – managed to get it all working using System.Net and some reading.


Leave a Reply