Mail Server Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationMail Server Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 25th, 2011, 01:05 PM
irmorteza irmorteza is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 18 irmorteza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 57 m 16 sec
Reputation Power: 0
Custom mail sending error

Hi

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 = "mymail@gmail.com";
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)
{
try
{
//create mail.
MailMessage message = new MailMessage();
message.From = new MailAddress(EmailDisplayName + "<" + EmailFrom + ">");
message.To.Add(new MailAddress(EmailTo));
message.Subject = Subject;
message.Body = "Stream, MediaTypeNames.Text.Html";

//Create alternate view.
string htmlBody = Body;
AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);

message.AlternateViews.Add(avHtml);

SmtpClient sc = new SmtpClient(Host);
sc.Port = Port;

sc.Credentials = new NetworkCredential(EmailFrom, Password);
sc.EnableSsl = true;
sc.Send(message);
return true;
}
catch (Exception ex)
{
return false;
}
}
}


Best Regards.
morteza

Reply With Quote
  #2  
Old November 12th, 2011, 03:13 AM
irmorteza irmorteza is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 18 irmorteza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 57 m 16 sec
Reputation Power: 0
Hi
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. ”
http://technet.microsoft.com/en-us/library/cc758523(WS.10).aspx
I hope this helpful

Best Regards.
Morteza.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationMail Server Help > Custom mail sending error

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap