by
0
7
1,591
0
Top 1% !
Popular
Famous
Easy-to-find
Specified
Refined
OpenSource
Popularity: 15208th place

Published on:

InputName0messageText
InputName1streamAttachment
InputType0string
InputType1Stream
LanguageCSharp
LicenseMIT_X11
MethodNameSendMessage
OSWindows
OutputTypevoid

SendMessage: Send SMTP message.           Most of the parameters are stored in the SSO.

<summary>
Send SMTP message.
Most of the parameters are stored in the SSO.
</summary>
<param name="messageText">Text of the mail</param>
<param name="XLANGMessage">Message send in attachment</param>
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/286201/SendMessage--Send-SMTP-message----------?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
using System; using System.Collections.Generic; using System.Text; using System.Net.Mail; using System.Net.Mime; using System.IO; using System.Xml; /// <summary> /// Send SMTP message. /// Most of the parameters are stored in the SSO. /// </summary> /// <param name="messageText">Text of the mail</param> /// <param name="XLANGMessage">Message send in attachment</param> public static void SendMessage(string messageText, Stream streamAttachment) { string to; string from; string cc; string subject; string host; int smtpPort; string username; string password; GetSmtpParams(out to, out from, out cc, out subject, out host, out smtpPort, out username, out password); MailMessage message = new MailMessage(from, to); message.Subject = subject; message.Body = messageText; message.IsBodyHtml = true; System.Net.Mime.ContentType customStreamAttachmentContentType = new System.Net.Mime.ContentType(); Attachment attachment = new Attachment(streamAttachment, MediaTypeNames.Application.Octet); //attachment.TransferEncoding = TransferEncoding.Base64; message.Attachments.Add(attachment); SmtpClient client = new SmtpClient(host, smtpPort); client.Credentials = new System.Net.NetworkCredential(username, password); client.Send(message); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus