Welcome to MSDN Blogs Sign in | Join | Help

Workflow problem in sending Email attachments of large file size

When a large file size ( typically > 1 MB ) is sent as an Email attachment through Workflow, we might see timed out exception.  The exact error message is “System.Net.Mail.SmtpException: The operation has timed out.  at System.Net.Mail.SmtpClient.Send(MailMessage)”

 

To overcome this, rather than just sending email via SMTP, pickup directory can be used in which case the IIS takes the responsibility of delivering the emails with attachment.   

 

SmtpClient client = new SmtpClient();

client.Host = "hostname";

client.Port = 2095;

client.Credentials = new System.Net.NetworkCredential("username", "password");

client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; 

 

MailAddress from = new MailAddress(“FromEmailID”);

MailAddress to = new MailAddress("ToEmailID”);

 

// Specify the file location

Attachment att1 = new Attachment("c:\\Test.doc");

MailMessage msg = new MailMessage(from, to);

 

msg.Subject = "Mail Test Success...";

msg.Attachments.Add(att1);

msg.Body = "some text for message body";

try

{

     client.Send(msg);

      MessageBox.Show("Mail Was Sent Successfully...");

}

catch (Exception ex)

{

        //Exception Handling Mechanism

}

Published Tuesday, June 02, 2009 4:17 PM by chandrasekarn

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Workflow problem in sending Email attachments of large file size | ASP NET Hosting

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker