-1

私はこのような電子メールの外観を与えようとしています:

   This is the looks of my email

ここに画像の説明を入力 メールの件名の右側は Ignou のロゴで、jpg 画像です。メールを送信するための次のクラスがあり、正常に動作しています。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Configuration;
    using System.Net.Configuration;
    using System.Net.Mail;

    namespace ProductManagementweb.HelperClasses
    {
      public class SendEmail
    {
    public static int SendMail(string ReceiverAddress, string Recsubject, string Recbody)
    {
        try
        {
            System.Configuration.Configuration config =                        WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
            MailSettingsSectionGroup settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");

            System.Net.NetworkCredential credential = new System.Net.NetworkCredential(settings.Smtp.Network.UserName, settings.Smtp.Network.Password);

            //Create the SMTP Client
            SmtpClient client = new SmtpClient();
            client.Host = settings.Smtp.Network.Host;
            client.Credentials = credential;
            client.Timeout = 30000;
            client.EnableSsl = true;

            MailMessage mm = new MailMessage();
            mm.From = new MailAddress(settings.Smtp.Network.UserName, "Support Team (Clique City)");
            mm.To.Add(ReceiverAddress);
            mm.Priority = MailPriority.High;


            // Assign the MailMessage's properties
            mm.Subject = Recsubject;
            mm.Body = Recbody;
            mm.IsBodyHtml = false;


            client.Send(mm);
            return 1;
        }

        catch (Exception ex)
        {
            throw ex;

        }
    }
  }
}

上の画像のようなメール形式を指定するにはどうすればよいですか。html タグを使用して形式について言及する必要があることは確かですが、どこでどのように言及する必要があるかは不明です。したがって、どんな助けもきっとありがたいです。

4

2 に答える 2

1

電子メール デザインの html コンテンツを Recbody、つまり電子メールの本文に配置し、変更する必要があります。

mm.IsBodyHtml = false;

mm.IsBodyHtml = true;
于 2013-10-09T09:11:07.487 に答える
0

vivekd の回答に加えて。

コードでHTMLを構築するだけです。

string messageContent = "";
messageContent += "<table><tr><td>" + telephoneNumber + "</td><td>" + locationAddress + "</td></tr></table>"

次に、

mm.IsBodyHtml = true;

そして、送信された電子メールの内容は、messageContent

mm.Body = messageContent;

明らかに、メールのレイアウトを自分で設計し、文字列に追加して構築する必要がありmessageContentます。

于 2013-10-09T09:29:31.660 に答える