hex, Just make sure that you have the correct permissions to where you are trying to save the uploaded file to. Checking this first will save you a ton of time in the long run.
Is that really necessary? I mean shouldn't the ASP user have sufficient permissions on the directory where the application is being run from to be able to attach a file to an e-mail ? This shouldn't be rocket science, but it really being a pain in the a@@.
Ok, I created a control to use multiple smtp servers and load balancing as well as a queue to re-send emails with problems and track them. Maybe this is easier for people to use:
// Create an array of all mail servers, mail server clusters and IPs you want to use ArrayList aList = new ArrayList();
aList.Add("mail.domain.com");
aList.Add("mail.cluster2.com");
aList.Add("192.168.1.25");
// Use it the same way than MailMessage FreeMail.BetterMailMessage oMessage = new FreeMail.BetterMailMessage();
oMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; oMessage.IsBodyHtml = false;
oMessage.Priority = MailPriority.High;
oMessage.Subject = "This is the subject";
oMessage.Body = TextBox2.Text;
MailAddress oFrom = new MailAddress("support@domain.com","Your Name");
oMessage.From = oFrom;
oMessage.To.Add("bob@yahoo.com");
// This is the main class, you can set Load Balancing
// Tracking Url to call back when the user opens the email
// You can use SSL or Smtp Authentication like SmtpClient class FreeMail.FreeMail oMail = new FreeMail.FreeMail(aList);
oMail.LoadBalancing = true;
oMail.TrackingUrl = "http://codeproject.com/track.aspx";
oMail.Send(oMessage);
I have used MailHelper class and call this function SendMailMessage,
But i am experiacing the following exceptin. i also updated Web.Config as required.
System.Net.Mail.SmtpException: Failure sending mail. ---> System.FormatException: Smtp server returned an invalid response. at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[]
buffer, Int32 offset, Int32 read, Boolean readLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.SmtpReplyReader.ReadLine()
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of
inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at MailHelper.SendMailMessage(String from, String to, String bcc, String cc, String subject, String body) in
[quote user="Ez416"]whats wrong? my error is Unable to read data from the transport connection: net_io_connectionclosed.
There's an error I haven't seen before. I searched around Google and it looks like you'll either need to use the exact IP address of the mail server or set it to (All unassigned) in IIS.
Blake05
Contributor
2561 Points
511 Posts
Re: HOW TO: Send email using System.Net.Mail
May 18, 2006 06:45 AM|LINK
Blog - Website: windowscoding.com
hexOffender
Member
20 Points
6 Posts
Re: HOW TO: Send email using System.Net.Mail
May 18, 2006 03:25 PM|LINK
Blake,
I have a feeling it is a permissions issue, since the error message does not have the path to the file, only ' '.
on the app folder IUSER_machineName has full control. What other permissions do I need to set?
Thanks for all the help
Blake05
Contributor
2561 Points
511 Posts
Re: HOW TO: Send email using System.Net.Mail
May 19, 2006 07:04 AM|LINK
Blog - Website: windowscoding.com
XIII
All-Star
182702 Points
23463 Posts
ASPInsiders
Moderator
MVP
Re: HOW TO: Send email using System.Net.Mail
May 19, 2006 08:49 AM|LINK
Hi,
it's better to create a dedicated windows user account and impersonate with that one. Use the <identity> element in the web.config.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
hexOffender
Member
20 Points
6 Posts
Re: HOW TO: Send email using System.Net.Mail
May 22, 2006 02:55 PM|LINK
albertpascua...
All-Star
17520 Points
3475 Posts
MVP
Re: HOW TO: Send email using System.Net.Mail
May 22, 2006 03:08 PM|LINK
Ok, I created a control to use multiple smtp servers and load balancing as well as a queue to re-send emails with problems and track them. Maybe this is easier for people to use:
// Create an array of all mail servers, mail server clusters and IPs you want to useArrayList aList = new ArrayList();
aList.Add("mail.domain.com");
aList.Add("mail.cluster2.com");
aList.Add("192.168.1.25");
// Use it the same way than MailMessage
FreeMail.BetterMailMessage oMessage = new FreeMail.BetterMailMessage();
oMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; oMessage.IsBodyHtml = false;
oMessage.Priority = MailPriority.High;
oMessage.Subject = "This is the subject";
oMessage.Body = TextBox2.Text;
MailAddress oFrom = new MailAddress("support@domain.com","Your Name");
oMessage.From = oFrom;
oMessage.To.Add("bob@yahoo.com");
// This is the main class, you can set Load Balancing
// Tracking Url to call back when the user opens the email
// You can use SSL or Smtp Authentication like SmtpClient class
FreeMail.FreeMail oMail = new FreeMail.FreeMail(aList);
oMail.LoadBalancing = true;
oMail.TrackingUrl = "http://codeproject.com/track.aspx";
oMail.Send(oMessage);
You can download it from here http://alpascual.com/control/bettermailmessage.htm
Cheers
Al
Al
My Blog
iasaghar
Member
5 Points
2 Posts
Re: HOW TO: Send email using System.Net.Mail
Jun 01, 2006 01:11 PM|LINK
Hi,
I have used MailHelper class and call this function SendMailMessage, But i am experiacing the following exceptin. i also updated Web.Config as required.
System.Net.Mail.SmtpException: Failure sending mail. ---> System.FormatException: Smtp server returned an invalid response. at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.SmtpReplyReader.ReadLine() at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at MailHelper.SendMailMessage(String from, String to, String bcc, String cc, String subject, String body) in
Smtp Server is working fine with VS 2003.
Regards,
Izhar Ahmad
albertpascua...
All-Star
17520 Points
3475 Posts
MVP
Re: HOW TO: Send email using System.Net.Mail
Jun 01, 2006 02:51 PM|LINK
I re wrote the mail class for 2.0 as promissed. Please download the control and let me know if works for you
http://alpascual.com/blog/al/archive/2006/04/06/146.aspx
Please post results into this Thread.
Cheers
Al
Al
My Blog
Ez416
Participant
1088 Points
607 Posts
Re: HOW TO: Send email using System.Net.Mail
Aug 29, 2006 05:07 AM|LINK
whats wrong? my error is
Unable to read data from the transport connection: net_io_connectionclosed.
i just copy the file then place it to APP_code folder
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Aug 29, 2006 05:34 AM|LINK
[quote user="Ez416"]whats wrong? my error is Unable to read data from the transport connection: net_io_connectionclosed.
There's an error I haven't seen before. I searched around Google and it looks like you'll either need to use the exact IP address of the mail server or set it to (All unassigned) in IIS.
Ryan