PDA

View Full Version : Using ASP.NET to Send Mail to Discountasp


stockpicker
04-24-2011, 03:05 AM
I am not able to use the mail class to send mail to or from my discountasp mail account. I am using c#.

This is what I am trying:

MailMessage mail = new MailMessage();

mail.IsBodyHtml = true;

//set the addresses
mail.From = new MailAddress(strUserEmail);
mail.To.Add(new MailAddress("Support@StockPickerMax.com"));

//set the content
mail.Subject = "Error Notice - StockPickerMax";
mail.Body = strBody;

//send the message
if (strConnection.Contains("StockProSQL")) // Local server
{
// do not send mail;
}
else // Remote server
{
SmtpClient smtp = new SmtpClient("smtp.stockpickermax.com", 8889);

smtp.Send(mail);
}

This is the error:

No connection could be made because the target machine actively refused it 64.79.170.142:8889
Description: An unhandled exception occurred during the execution of the current web request.

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 64.79.170.142:8889

Source Error:


Line 182: SmtpClient smtp = new SmtpClient("smtp.stockpickermax.com", 8889);
Line 183:
Line 184: smtp.Send(mail);
Line 185: }
Line 186: conStockSelect.Close();

I received the following from discountasp support:

You will either have to use "localhost" which doesn't require authentication when sending, or you'll have to use your SMTP server (smtp.stockpickermax.com) using a valid email address (ie. User@stockpickermax.com) with the password to the account.

------

"localhost" does not work for me.

I need toknow how to code the following:

or you'll have to use your SMTP server (smtp.stockpickermax.com) using a valid email address (ie. User@stockpickermax.com) with the password to the account.

Thanks,

wisemx
04-25-2011, 05:15 AM
...Take a look at this see if it helps, re-post if you need more help:
http://wiki.asp.net/page.aspx/536/send-asynchronous-mail-using-aspnet/

Tasslehoff
04-25-2011, 05:23 AM
When you use 'localhost' as your SMTP server, leave the username and password blank (i.e. don't set them).

stockpicker
04-25-2011, 06:32 AM
The following code resolved this for me.

SmtpClient smtp = new SmtpClient("smtp.stockpickermax.com", 25);
NetworkCredential Credentials = new NetworkCredential("support@stockpickermax.com", "mypassword");
smtp.Credentials = Credentials;

smtp.Send(mail);

wisemx
04-25-2011, 11:43 AM
...Awesome.