Commits

Scott Anderson committed 097e935

Making sure that inline attachments have a "multipart/related" mime type.

Comments (0)

Files changed (2)

src/ActionMailer.Net.Tests/MailerBaseExtensionsTests.cs

             Assert.Equal("logo.png", attachment.ContentId);
             Assert.Equal("logo-inline.png", inlineAttachment.ContentId);
             Assert.Equal("image/png", attachment.ContentType.MediaType);
-            Assert.Equal("image/png", inlineAttachment.ContentType.MediaType);
+            Assert.Equal("multipart/related", inlineAttachment.ContentType.MediaType);
             Assert.True(inlineAttachment.ContentDisposition.Inline);
             Assert.True(attachmentBytes.SequenceEqual(logoBytes));
             Assert.True(inlineAttachmentBytes.SequenceEqual(logoBytes));

src/ActionMailer.Net/MailerBaseExtensions.cs

             // ideally we'd like to find the mime type for each attachment automatically
             // based on the file extension.
             string mimeType = null;
-            var extension = fileName.Substring(fileName.LastIndexOf("."));
-            if (!string.IsNullOrEmpty(extension))
-                mimeType = MimeTypes.ResolveByExtension(extension);
+
+            if (inline) {
+                mimeType = "multipart/related";
+            } else {
+                var extension = fileName.Substring(fileName.LastIndexOf("."));
+                if (!string.IsNullOrEmpty(extension))
+                    mimeType = MimeTypes.ResolveByExtension(extension);
+            }
 
             var stream = new MemoryStream(fileContents);
             var attachment = new Attachment(stream, fileName, mimeType);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.