Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small issue with attachments #87

Open
mediocreguy opened this issue Jul 2, 2012 · 1 comment
Open

Small issue with attachments #87

mediocreguy opened this issue Jul 2, 2012 · 1 comment

Comments

@mediocreguy
Copy link

Great assembly!
However, when implementing the assembly in a project I was working on, I was having a small problem with the attachments I was processing. Sometimes text attachments would have extra blank lines and would cause MailMessage.ParseMime() to read attempt to read past the end of the message. I think when reading the part body the method needs to read until it encounters the next boundary instead of stopping on a blank line. I would suggest trying the following patch to MailMessage.cs:

-        // header body
+        // read part body - must read to the next inner boundary
         data = reader.ReadLine(ref maxLength, Encoding);
         var body = new StringBuilder();
-        while (data != string.Empty && !data.StartsWith(bounderInner)) {
+        while (!data.StartsWith(bounderInner) && (maxLength > 0 || !maxLengthSpecified)) {
           body.AppendLine(data);
           data = reader.ReadLine(ref maxLength, Encoding);
         }
+

I've done some limited testing and it appears to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@mediocreguy and others