Sunday 15 June 2014

c# - How to format text in email when using smtp -


I am using the following method to send an email. I should be able to format emails with bold text I want

East.

From: Name

Email: Email Address

Message: Message

How can I do this?

  Protected Zero SendMail () {var fromAddress = "myemail@gmail.com"; Var toAddress = "myotheremail@gmail.com"; Password string = "mypassword"; String subject = "new email from website"; String body = "to:" + name.Text + "\ n"; Body + = "email:" + email Text + "\ n"; Body + = "Message: \ n" + Message. Text + "\ n"; Var smtp = New System.Net.Mail.SmtpClient (); {Smtp.Host = "smtp.gmail.com"; Smtp.Port = 587; Smtp.EnableSsl = true; Smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; Smtp.Credentials = New network credentials (from page, from address); Smtp.Timeout = 20000; } // passing the value to smtp.Send the STMT object (from aadder, aadder, subject, body); }    

set isBodyHtml is correct, description of the following code, sending a bold text You can use " & lt; b & gt; my bold text & lt; / b & gt; ". You can use " i & gt; Italic Text & lt; / i & gt; " to send a skewed text. You can use " underlined text " to send an underlined text.

You can copy and use the following method, using this method will be very easy to send email. Public Static Bull SendEmail (String To, String ToName, String, String Name, String Subject, String Body, Bull ISBODHML) {{MailAddress FromAddr = New Mail Address (From, Sender Name, System .text encoding.utf8); MailAddress toAddr = New Mail Address (To, ToName, System.Text.Encoding.UTF8); Var smtp = New SmtpClient {host = "smtp.gmail.com", port = 25, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = New System.Net.NetworkCredential ("Your Email Address", " your password") }; (MailMessage Message = Using new MailMessage (AAADR, Tooder) {subject = theme, body = body, ISBDHML = ISBDIHML, body encoding = systemtext.NNcoding.UTF8,}) {SMTPandend (message); } Back true; } Hold {return false; }}

When you call this method, call it like this

  SendEmail ("address from here", "name from here"    

No comments:

Post a Comment