mailgun apiを使用してメールを送信する際に、メールコンテンツ内にhtmlタグを設定するにはどうすればよいですか?私はそれを送信すると、タグはそのまま表示されます。MailGunを使用してメールにHTMLコンテンツを送信
しかし、SMTPで、ここでは、としてそれを設定することができisBodyHtml = trueを
mailgun apiを使用してメールを送信する際に、メールコンテンツ内にhtmlタグを設定するにはどうすればよいですか?私はそれを送信すると、タグはそのまま表示されます。MailGunを使用してメールにHTMLコンテンツを送信
しかし、SMTPで、ここでは、としてそれを設定することができisBodyHtml = trueを
は、HTML形式の電子メールを送信するためにあなたを助けることができる迅速なコード例です。
RestClient client = new RestClient();
client.BaseUrl = new Uri("https://api.mailgun.net/v3");
RestRequest request = new RestRequest();
client.Authenticator = new HttpBasicAuthenticator("api", "key-XXX");
request.AddParameter("domain","yourdomain.com", ParameterType.UrlSegment);
request.Resource = "{domain}/messages";
//request.AddParameter("from", "Mailgun Sandbox <[email protected]>");
request.AddParameter("from", "[email protected]");
request.AddParameter("to", to);
request.AddParameter("subject", subject);
request.AddParameter("text", "Text view of this email is not supported. Please view this email in HTML format. Thank you.");
//This will help you to send email in HTML format
request.AddParameter("html", body);
request.Method = Method.POST;
RestResponse stat = client.Execute(request) as RestResponse;
希望します。
Mailgun APIを呼び出すときに、HTMLコンテンツ(タグ付き)を 'html'パラメータに入れることができます。 は(最後の行は、あなたが求めているものです)Mailgunのホームページから撮影:
POST /messages
from = 'App <[email protected]>'
to = '[email protected]'
subject = 'Hello'
text = 'Welcome to our amazing app!'
html = '<p>Welcome to our amazing app!</p>'
が、これは
を役に立てば幸い