July 25th, 2011, 01:05 PM
Custom mail sending error
I have C# code to send mail through gmail server. But when i want to use it in my server(win2003), it not work.
I had another server(win2003) and this code worked correctly on it, and it work correctly in my local computer(win7).
Do anyone know what is the problem?
public class EMail
static string EmailFrom = "firstname.lastname@example.org";
static string EmailDisplayName = "display name";
static string Password = "myPassword";
static string Host = "smtp.gmail.com";
//static int Port = 587;
static int Port = 465;
static public bool SendMail(string Subject, string Body, string EmailTo)
MailMessage message = new MailMessage();
message.From = new MailAddress(EmailDisplayName + "<" + EmailFrom + ">");
message.Subject = Subject;
message.Body = "Stream, MediaTypeNames.Text.Html";
//Create alternate view.
string htmlBody = Body;
AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
SmtpClient sc = new SmtpClient(Host);
sc.Port = Port;
sc.Credentials = new NetworkCredential(EmailFrom, Password);
sc.EnableSsl = true;
catch (Exception ex)
November 12th, 2011, 03:13 AM
The server was Windows2003server-64bit, and the problem was 64bit. I change it to 32bit and it works fine now.
Unfortunately .Net Framework not supported in win2003-64bit, completely.
For more detail go to following link and read “.NET Application Services” section, and its checkpoint in under of table: “(2) Not supported in 64-bit versions of Windows Server 2003. ”
I hope this helpful