C# emailing SSL with bluehost
I know that it says you can do it but what is the secret? I am trying to use Bluehost's SSL email feature to send emails utilizing a C# app I wrote.
Can someone please help? I did try and ask Bluehost but they "don't provide support for custom coding."
Here is the code:
Replace all "yourname" with your actual site to test.
private bool EmailTest()
// Create a mailing address that includes a UTF8 character in the display name.
MailAddress oFromAddress = new MailAddress("firstname.lastname@example.org", "Your Name");
// Set destinations for the e-mail message.
MailAddress oToAddress = new MailAddress("email@example.com");
// Specify the message content.
MailMessage oMailMessage = new MailMessage(oFromAddress, oToAddress);
oMailMessage.Body = "This is a test e-mail message sent by an application. ";
oMailMessage.BodyEncoding = Encoding.UTF8;
oMailMessage.Subject = "test SSL message from bluehose";
oMailMessage.SubjectEncoding = Encoding.UTF8;
oMailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
// sending using SSL
string smtpServer = "box100.bluehost.com";
int smtpPort = 465;
SmtpClient oSMTPClient = new SmtpClient(smtpServer, smtpPort);
oSMTPClient.Host = "mail.yourhost.com";
oSMTPClient.UseDefaultCredentials = false;
NetworkCredential smtpCcredentials = new System.Net.NetworkCredential("yourname@yourdomain. com", "yourpassword");
oSMTPClient.Credentials = smtpCcredentials;
oSMTPClient.EnableSsl = true;
oSMTPClient.DeliveryMethod = SmtpDeliveryMethod.Network;
oSMTPClient.Timeout = 5000;
catch (Exception ex)
I am getting typical, unhelpful message, "The operation has timed out." which indicates no connection. No changing the SMTP timeout to a higher value does not work. I have tested this with gmail's SSL and it works.
Tags for this Thread