English 中文(简体)
行动邮件MVC3和内嵌图像
原标题:Action Mailer MVC3 and Inline Image

CI 正在使用 MVC 。 Action Mailler 从我的网站发送电子邮件。 我对将内嵌图像嵌入电子邮件有问题 。

这里是我的主计长行动

public EmailResult WelcomeEmail()
    {
        WelcomeMailVM welcomeDetails = new WelcomeMailVM()
        var path = HttpContext.Current.Server.MapPath("~/Content/images/myImage.png");
        Attachments.Add("myImage.png", System.IO.File.ReadAllBytes(path));
        //Attachments.Inline["holidaymate.png"] = System.IO.File.ReadAllBytes(path);
        To.Add("[email protected]");
        From = "[email protected]";
        Subject = "Welcome to My Site;
        return Email("WelcomeEmail", welcomeDetails);
    }

和电子邮件的视图

@model HolidayMate.API.ViewModels.Mail.WelcomeMailVM
@using ActionMailer.Net.Mvc

@{
     Layout = "~/Views/Shared/_MailLayout.cshtml";
 }
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

 <table cellpadding="0" cellspacing="0" border="0" id="backgroundTable">
 <tr>
    <td style="width:300px">
        @Html.InlineImage("myImage.png")
    </td>
    <td style="width:300px">
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td>Date</td>
                <td>@DateTime.Now.ToString("dd MMMM yyyy")
                </td>
            </tr>
        </table>
    </td>
</tr>
</table>

电子邮件发送完美。 但图像没有在电子邮件中显示 。 我理解 gmail 和雷鸟的问题 。 不幸的是, 我没有前景可以测试 。 谷歌时我发现了以下

中显示

但我不知道该邮件的内容类型会发送到何处。 请您给予任何帮助。

最佳回答

我用的是MVC Mailer 而不是Action Mailler 现在图像效果很好

但我现在不能发送电子邮件 除非我使用以下 SMTP 设置, 否则我的正常设置无法工作

<mailSettings >
  <smtp deliveryMethod="Network" from="[email protected]">
    <network enableSsl="true" host="mail.mySMTP.com" port="25"  defaultCredentials="true" />
  </smtp>
</mailSettings>

不工作,但当使用以下工具时有效

<mailSettings >
  <smtp deliveryMethod="Network" from="[email protected]">
      network enableSsl="true" host="smtp.gmail.com" port="587" userName="[email protected]" password="mypassword"/>
  </smtp>
</mailSettings>
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签