Thanks Strongtypes, work better now. I downloaded the file directly from the download page so I never touched it. Besides I don't even know what to touch in it. Anyway, I tried the code after the adjustment (Thanks) and it gave me the following Message.
Failure sending mail and highlighted the mSmtpClient.Send(mMailMessage) during the debugging mode.
Q: is it meant to create a page for user to type in or what precisely does it do or does it just send an express mail, cos I notice I didn't specify any e-mail address to send to. Thanks for your help.
I downloaded the file directly from the download page so I never touched it.
That's weird as I just downloaded it and the code is fine.
linkyossy
Failure sending mail and highlighted the mSmtpClient.Send(mMailMessage) during the debugging mode.
That's due to some SMTP authentication issue most likely, so I suggest that you look at
SystemNetMail.com.
linkyossy
is it meant to create a page for user to type in or what precisely does it do or does it just send an express mail
Where you get the input for email addresses and other values is up to you. The code is just a helper. You can use it as-is and pass values to it, or use the code directly in the web form.
What about when the smtp server is a cluster of MX records with priorities 10, 20, 30, etc? The class does not select priority 10 and does not use the next MX record if the first one fails. I made some modifications to your code to fix this issues, if you
want I can post them here or send them by email to you.
What about when the smtp server is a cluster of MX records with priorities 10, 20, 30, etc? The class does not select priority 10 and does not use the next MX record if the first one fails.
Hi Al,
I was trying to keep it as simple as possible as I was targeting people who need help with the basics. However, I think it would be cool if you posted the modifications as a reply to this thread for those who are interested
in that can see how to do it. Thanks.
My fault, I went back and I read the complete thread. I confused this with another in microsoft communities. Don't want to confuse anyone else, your class is fantastic to send emails. Wanted to make sure the performance and the exception when the mail server
is handle using
IPHostEntry
local = Dns.Resolve(settingkey);
to get the list of IP for that MX record
foreach (IPAddress ipaddress
in local.AddressList)
and add a try and catch around the Send() until you find a mail server that does not give you an exception. And overkill to send emails.
Also I did it for System.Net.Mail
So, sorry about that, however I may create that function if you want for your class. Do you think is worth it?
linkyossy
Member
485 Points
98 Posts
Re: HOW TO: Send email using System.Net.Mail
Mar 20, 2006 08:36 AM|LINK
Thanks Strongtypes, work better now. I downloaded the file directly from the download page so I never touched it. Besides I don't even know what to touch in it. Anyway, I tried the code after the adjustment (Thanks) and it gave me the following Message. Failure sending mail and highlighted the mSmtpClient.Send(mMailMessage) during the debugging mode.
Q: is it meant to create a page for user to type in or what precisely does it do or does it just send an express mail, cos I notice I didn't specify any e-mail address to send to. Thanks for your help.
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Mar 20, 2006 08:49 AM|LINK
That's weird as I just downloaded it and the code is fine.
That's due to some SMTP authentication issue most likely, so I suggest that you look at SystemNetMail.com.
Where you get the input for email addresses and other values is up to you. The code is just a helper. You can use it as-is and pass values to it, or use the code directly in the web form.
HTH,
Ryan
linkyossy
Member
485 Points
98 Posts
Re: HOW TO: Send email using System.Net.Mail
Mar 20, 2006 08:53 AM|LINK
albertpascua...
All-Star
17520 Points
3475 Posts
MVP
Re: HOW TO: Send email using System.Net.Mail
Mar 21, 2006 09:58 PM|LINK
What about when the smtp server is a cluster of MX records with priorities 10, 20, 30, etc? The class does not select priority 10 and does not use the next MX record if the first one fails. I made some modifications to your code to fix this issues, if you want I can post them here or send them by email to you.
Cheers
Al
Al
My Blog
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Mar 22, 2006 12:10 AM|LINK
Hi Al,
I was trying to keep it as simple as possible as I was targeting people who need help with the basics. However, I think it would be cool if you posted the modifications as a reply to this thread for those who are interested in that can see how to do it. Thanks.
albertpascua...
All-Star
17520 Points
3475 Posts
MVP
Re: HOW TO: Send email using System.Net.Mail
Mar 22, 2006 12:22 AM|LINK
My fault, I went back and I read the complete thread. I confused this with another in microsoft communities. Don't want to confuse anyone else, your class is fantastic to send emails. Wanted to make sure the performance and the exception when the mail server is handle using
IPHostEntry
local = Dns.Resolve(settingkey);to get the list of IP for that MX record
foreach (IPAddress ipaddress in local.AddressList)
and add a try and catch around the Send() until you find a mail server that does not give you an exception. And overkill to send emails.
Also I did it for System.Net.Mail
So, sorry about that, however I may create that function if you want for your class. Do you think is worth it?
Cheers
Al
Al
My Blog
XIII
All-Star
182707 Points
23464 Posts
ASPInsiders
Moderator
MVP
Re: HOW TO: Send email using System.Net.Mail
Mar 22, 2006 05:18 AM|LINK
Defenitely.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
albertpascua...
All-Star
17520 Points
3475 Posts
MVP
Re: HOW TO: Send email using System.Net.Mail
Mar 22, 2006 02:44 PM|LINK
I'll put myself into work then!
Cheers
Al
Al
My Blog
Tj@y
Member
35 Points
7 Posts
Re: HOW TO: Send email using System.Net.Mail
Mar 22, 2006 06:15 PM|LINK
Quick thoguht, my messages are stuck in the queue folder in the mail root directory and they are not getting sent am I missing something?
Here is my code
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("bee@honey.com);
mail.To.Add("bee@honey.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
//send the message
SmtpClient smtp = new SmtpClient("localhost");
try
{
smtp.Credentials = new System.Net.NetworkCredential("meh", "l4m3r");
smtp.Send(mail);
}
catch (Exception ex)
{
Exception ex2 = ex;
string errorMessage = string.Empty;
while (ex2 != null)
{
errorMessage += ex2.ToString();
ex2 = ex2.InnerException;
}
Response.Write(errorMessage);
}
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Mar 22, 2006 06:23 PM|LINK
What happens if you change the SMTP port in IIS to something like 2525 and also in your code? Also, are there any messages in the BadMail folder?
HTH,
Ryan