by
0
6
1,821
1
Top 1% !
Famous
Easy-to-find
Specified
Tuned
OpenSource
Popularity: 11287th place

Published on:

InputName0smtpClient
InputName1from
InputName1message
InputName2recipients
InputName2userToken
InputName3subject
InputName4body
InputName5userToken
InputType0SmtpClient
InputType1MailMessage
InputType1string
InputType2object
InputType2string
InputType3string
InputType4string
InputType5object
LanguageCSharp
LicenseMIT_X11
MethodNameSendTask
OSWindows
OutputTypeTask

SendTask: Sends an e-mail message asynchronously.

<summary>Sends an e-mail message asynchronously.</summary>
<param name="smtpClient">The client.</param>
<param name="message">A MailMessage that contains the message to send.</param>
<param name="from">A String that contains the address information of the message sender.</param>
<param name="recipients">A String that contains the address that the message is sent to.</param>
<param name="subject">A String that contains the subject line for the message.</param>
<param name="body">A String that contains the message body.</param>
<param name="userToken">A user-defined object stored in the resulting Task.</param>
<returns>A Task that represents the asynchronous send.</returns>
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/291549/SendTask--Sends-an-e-mail-message-asynch?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.Net.Mail; using System.Threading.Tasks; /// <summary>Sends an e-mail message asynchronously.</summary> /// <param name="smtpClient">The client.</param> /// <param name="message">A MailMessage that contains the message to send.</param> /// <param name="from">A String that contains the address information of the message sender.</param> /// <param name="recipients">A String that contains the address that the message is sent to.</param> /// <param name="subject">A String that contains the subject line for the message.</param> /// <param name="body">A String that contains the message body.</param> /// <param name="userToken">A user-defined object stored in the resulting Task.</param> /// <returns>A Task that represents the asynchronous send.</returns> public static Task SendTask(this SmtpClient smtpClient, string from, string recipients, string subject, string body, object userToken) { return SendTaskCore(smtpClient, userToken, tcs => smtpClient.SendAsync(from, recipients, subject, body, tcs)); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus