Advertisements

Powershell Error – Index was outside the bounds of the array when using System.Net.Mail Class with Send-MailMessage cmdlet

Are you using the System.Net.Mail to send File Attachments? Is the file attachment above 3MB?

If yes; you have just found out the reason for the error. The System.Net.Mail Class throws an exception if a file attachment is over 3MB

Microsoft has a patch available which solves this issue

https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30226

If you have any issues downloading the file; you may post your comment on this post.

Once the patch is applied; you should now be able to send large attachments using your Powershell Send-MailMessage cmdlet.

Please ensure that you use the -UseSSL in your cmdlet. If you leave out -UseSSL; you are most likely to encounter the below error

Send-MailMessage : The operation has timed out.

 

Advertisements

Posted on June 8, 2014, in Powershell and tagged , . Bookmark the permalink. 1 Comment.

  1. We stumbled over here from a different website and thought I may as
    well check things out. I like what I see so i am just following you.

    Look forward to looking at your web page repeatedly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: