-1

AIM Aegis Implicit Mail を使用して Implicit ssl メールを送信しています。

メール メッセージで件名と本文を使用する場合は問題ありませんが、別のビューを使用するとメールの本文が空になります。この別のビューのセットアップは、メールメッセージで動作し、受信クライアントに応じて html とテキスト本文を持ちますが、デバッグ コードでは問題ないように見えますが、メールボックスで受信すると空である MimeMailMessage を使用する必要があります。

コードは次のとおりです。

string plainTextBody = "Welkom.";

AlternateView plainTextView =
    AlternateView.CreateAlternateViewFromString(
        plainTextBody, null, MediaTypeNames.Text.Plain);
plainTextView.ContentType = new System.Net.Mime.ContentType("text/plain");
mail.AlternateViews.Add(plainTextView);

string htmlBody = @"<html><body><img src=""cid:logo""><br /> Welkom </body></html>";

AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
htmlView.ContentType = new System.Net.Mime.ContentType("text/html");
string imageSource = Path.Combine(HttpRuntime.AppDomainAppPath, @"Content\Images\Logob.png");
LinkedResource PictureRes = new LinkedResource(imageSource, MediaTypeNames.Image.Jpeg);
PictureRes.ContentId = "logo";
htmlView.LinkedResources.Add(PictureRes);
mail.AlternateViews.Add(htmlView);
4

1 に答える 1

0

Aim は AlternativeView を提供していませんが、インライン添付ファイルを使用して画像を配置し、メッセージ本文に HTML コードを直接設定できます。サンプル コードをダウンロードして、インライン添付ファイルがどのように機能しているかを確認してください。

于 2015-07-18T17:41:09.337 に答える