Comments on: Send email with attachment https://www.limilabs.com/blog/send-email-with-attachment Thu, 08 Oct 2015 21:01:15 +0000 hourly 1 https://wordpress.org/?v=6.3.4 By: Limilabs support https://www.limilabs.com/blog/send-email-with-attachment#comment-422731 Mon, 21 Jan 2013 17:33:15 +0000 http://www.limilabs.com/blog/?p=1282#comment-422731 In reply to Tony.

@Tony,

What kind of error are you getting? What is the message, type, stack trace?

Are you sure that there exists a file at the location you specify?
You can use File.Exists to check.

Also there is no MailBuilder.AddAttachment overload that takes StringBuilder class as a parameter, did you meant:
builder.AddAttachment(tempFileName.ToString())?

]]>
By: Tony https://www.limilabs.com/blog/send-email-with-attachment#comment-422686 Mon, 21 Jan 2013 16:41:45 +0000 http://www.limilabs.com/blog/?p=1282#comment-422686 Hi,

I have an app that I am creating (C#, XAML). I have a .csv file that my app created and stores it in the following location:

StringBuilder tempFileName = new StringBuilder();
tempFileName.Append(ApplicationData.Current.LocalSettings.Values[“lastName”].ToString()).Append(“_”)
.Append(ApplicationData.Current.LocalSettings.Values[“firstName”].ToString()).Append(” – (“)
.Append(txtEventName.Text).Append(“).csv”);

Then I tried to attach this file to the email:
MimeData attachment = builder.AddAttachment(tempFileName);
attachment.ContentType = ContentType.TextPlain;

It is giving me an error. What am I doing wrong. I looked at the sample and did exactly what it says.

Thank you.

]]>
By: Limilabs support https://www.limilabs.com/blog/send-email-with-attachment#comment-214902 Tue, 20 Nov 2012 14:12:32 +0000 http://www.limilabs.com/blog/?p=1282#comment-214902 @Peter,

You can catch the exception thrown by Connect method.

]]>
By: Limilabs support https://www.limilabs.com/blog/send-email-with-attachment#comment-1503 Mon, 23 Jan 2012 18:49:43 +0000 http://www.limilabs.com/blog/?p=1282#comment-1503 In reply to Peter Steiness.

Peter,

As you might expect there is no direct conversion method.
You need to have data as byte array, ContentType object (you can parse it from string) and file name:

byte[] data = ...;
string contentType = ...;
string fileName = ...;

MimeData mime = new MimeFactory().CreateMimeData();
mime.Data = data;
mime.ContentType = ContentType.Parse(contentType);
mime.FileName = fileName;
]]>
By: Peter Steiness https://www.limilabs.com/blog/send-email-with-attachment#comment-1502 Mon, 23 Jan 2012 14:21:18 +0000 http://www.limilabs.com/blog/?p=1282#comment-1502 How do I convert a System.Net.Mail.Attachment object to a Limilabs.Mail.MIME.MimeData object?

ContentStream = Stream object.
Filename = String object.
ContentType = String object.

-Peter Steiness
NOVAQ – Qmanager.dk licens.

]]>