Send Email Using ASP.Net With C#
IntroductionÂ
There are many more articles on Google for sending an email using ASP.NET and C#. This article explains some important functions and notable errors.
Simple Mail Transfer Protocol (SMTP)
Simple Mail Transfer Protocol (SMTP) is a TCP/IP protocol used in sending and receiving e-mail. Most e-mail systems that send mail over the Internet use SMTP to send messages from one server to another. The messages can then be retrieved with an e-mail client using either POP or IMAP.
The following is a list of SMTP Server and Port Numbers:
Important SMTP Class Properties
- Host: Server URL for SMTP (check the preceding table).
- EnableSsl: Check your host accepts SSL Connections (True or False).
- Port: Port Number of the SMTP server (check the preceding table).
- Credentials: Valid login credentials for the SMTP server (the email address and password).
- UseDefaultCredentials: When we set to True in UseDefaultCredentials then that specifies to allow authentication based on the credentials of the account used to send emails.
=======================
Web Config AppSettings
=======================
<appSettings>
<add key="smtpClient" value="smtp.gmail.com" />
<add key="smtpUserName" value="Your Email" />
<add key="smtpPassword" value="Your password(App password)" />
<add key="smtpPort" value="587" />
<add key="enableSSL" value="true" />
<add key="smtpToEmailid" value="Your Email" />
</appSettings>
==============
SMTP Setting
==============
MailMessage mail = new MailMessage();
SmtpClient smtp_Client = new SmtpClient(System.Configuration.ConfigurationSettings.AppSettings["smtpClient"]);
smtpUserName = System.Configuration.ConfigurationSettings.AppSettings["smtpUserName"];
smtpPassword = System.Configuration.ConfigurationSettings.AppSettings["smtpPassword"];
mail.From = new MailAddress(smtpUserName);
mail.To.Add(txtEmailId.Text.Trim());
mail.Subject = "your Subject";
mail.Body = "Your Body";
smtp_Client.Port = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["smtpPort"]);
smtp_Client.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPassword);
smtp_Client.EnableSsl = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["enableSSL"]);
smtp_Client.Send(mail);
QuillBot’s AI-powered paraphrasing tool will enhance your writing
Your words matter, and our paraphrasing tool is designed to ensure you use the right ones. With two free modes and five Premium modes to choose from, you can use QuillBot’s online Paraphraser to rephrase any text in a variety of ways. Our product will improve your fluency while also ensuring you have the appropriate vocabulary, tone, and style for any occasion. Simply enter your text into the input box, and our AI will work with you to create the best paraphrase.
Quillbot Extension For Chrome
Features of Semrush Cookies
SemRush is a powerful tool for online marketing, and one of its key features is the ability to track your online activity with cookies. By tracking your online activity, SemRush can provide you with valuable insights into your marketing campaigns and help you optimize your website for better results.
One of the most useful features of SemRush is the ability to track your keywords. With this feature, you can see which keywords are driving traffic to your website and which ones are not. This information can be used to adjust your marketing strategy and improve your results.
Another useful feature of SemRush is the ability to track your backlinks. This feature can be used to see which websites are linking to your website and which ones are not. This information can be used to improve your website’s search engine optimization and increase your visibility in the search engines.
Overall, SemRush is a powerful tool for online marketing. It provides valuable insights into your marketing campaigns and helps you optimize your website for better results.
Below are the some latest cookies for semrush which you can use these to access all the premium features of semrush.
[
{
"domain": "www.semrush.com",
"expirationDate": 1710174370.776613,
"hostOnly": true,
"httpOnly": false,
"name": "do-favorite-db",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "in"
},
{
"domain": "www.semrush.com",
"expirationDate": 1710140973,
"hostOnly": true,
"httpOnly": false,
"name": "sa-user-id-v2",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "s%253Aq0wvJH1zRqV_6RPrEUF1AQ.3AwX%252BFwLZx1QdEdQadDj1jbv5ebr4%252FsqWvp1rWI5dAw"
},
{
"domain": ".semrush.com",
"expirationDate": 1710759846,
"hostOnly": false,
"httpOnly": false,
"name": "_mkto_trk",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "id:519-IIY-869&token:_mch-semrush.com-1679133113584-40561"
},
{
"domain": ".semrush.com",
"expirationDate": 1679223872,
"hostOnly": false,
"httpOnly": false,
"name": "_dc_gtm_UA-6197637-22",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "1"
},
{
"domain": ".semrush.com",
"expirationDate": 1710174390.953456,
"hostOnly": false,
"httpOnly": false,
"name": "__insp_targlpt",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": null,
"value": "U2VtcnVzaA%3D%3D"
},
{
"domain": ".semrush.com",
"expirationDate": 1710174391.430729,
"hostOnly": false,
"httpOnly": false,
"name": "__insp_norec_sess",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": null,
"value": "true"
},
{
"domain": ".semrush.com",
"expirationDate": 1710669110,
"hostOnly": false,
"httpOnly": false,
"name": "ref_code",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "__default__"
},
{
"domain": ".www.semrush.com",
"expirationDate": 1713015730.163641,
"hostOnly": false,
"httpOnly": false,
"name": "G_ENABLED_IDPS",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "google"
},
{
"domain": "www.semrush.com",
"expirationDate": 1679310245,
"hostOnly": true,
"httpOnly": false,
"name": "ln_or",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "eyIzODc1MzgiOiJkIn0%3D"
},
{
"domain": ".semrush.com",
"expirationDate": 1712829113,
"hostOnly": false,
"httpOnly": false,
"name": "_ttp",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "bTapNQIbtENPVdpMrr7Cs2KWHgc"
},
{
"domain": ".www.semrush.com",
"expirationDate": 1710669114,
"hostOnly": false,
"httpOnly": false,
"name": "sa-user-id",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "s%253A0-fa9d869f-8e89-4956-7cd7-7f22ac8f4a4c.%252FhT7WMi1wsMFOnaC2oA7t9EuKOffBCVHBBRnKen3M%252FU"
},
{
"domain": ".semrush.com",
"expirationDate": 1691429070.202843,
"hostOnly": false,
"httpOnly": true,
"name": "referer_purchase",
"path": "/",
"sameSite": null,
"secure": true,
"session": false,
"storeId": null,
"value": "https%3A%2F%2Fsecure.semrush.com%2F"
},
{
"domain": ".semrush.com",
"expirationDate": 1686999844,
"hostOnly": false,
"httpOnly": false,
"name": "_rdt_uuid",
"path": "/",
"sameSite": "strict",
"secure": true,
"session": false,
"storeId": null,
"value": "1679133110517.1e061441-0239-4bcf-a310-73bc6b3ba3f0"
},
{
"domain": ".www.semrush.com",
"expirationDate": 1680171829,
"hostOnly": false,
"httpOnly": false,
"name": "_ampl",
"path": "/",
"sameSite": null,
"secure": true,
"session": false,
"storeId": null,
"value": "67b13OaFLqrDl6ajS-Acy"
},
{
"domain": ".semrush.com",
"expirationDate": 1710759843,
"hostOnly": false,
"httpOnly": false,
"name": "_ga_HYWKMHR981",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "GS1.1.1679223812.4.1.1679223843.29.0.0"
},
{
"domain": "www.semrush.com",
"expirationDate": 1679310234.880308,
"hostOnly": true,
"httpOnly": true,
"name": "GCLB",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "CMWDkeb1_N7aPw"
},
{
"domain": ".semrush.com",
"expirationDate": 1681457550.769981,
"hostOnly": false,
"httpOnly": false,
"name": "ga_exp_1549fa563f454be7a1bc1b2a",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "0"
},
{
"domain": ".semrush.com",
"expirationDate": 1712829113,
"hostOnly": false,
"httpOnly": false,
"name": "_tt_enable_cookie",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "1"
},
{
"domain": ".www.semrush.com",
"expirationDate": 1705645796,
"hostOnly": false,
"httpOnly": false,
"name": "__pdst",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "b5c4f823d650408cba754cd66af179a0"
},
{
"domain": ".semrush.com",
"expirationDate": 1686980539,
"hostOnly": false,
"httpOnly": false,
"name": "_fbp",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "fb.1.1679133113564.1830873144"
},
{
"domain": ".semrush.com",
"expirationDate": 1691429070.202933,
"hostOnly": false,
"httpOnly": false,
"name": "usertype",
"path": "/",
"sameSite": null,
"secure": true,
"session": false,
"storeId": null,
"value": "Paid-User"
},
{
"domain": ".semrush.com",
"expirationDate": 1710669110,
"hostOnly": false,
"httpOnly": false,
"name": "refer_source",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "\"\""
},
{
"domain": ".semrush.com",
"expirationDate": 1679310244,
"hostOnly": false,
"httpOnly": false,
"name": "_uetsid",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "e3737460c49b11ed978a0f50d6f999b2"
},
{
"domain": ".www.semrush.com",
"expirationDate": 1679310208.112785,
"hostOnly": false,
"httpOnly": true,
"name": "GCLB",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "CIXyg8vVqpSK5wE"
},
{
"domain": ".semrush.com",
"expirationDate": 1713693100.716582,
"hostOnly": false,
"httpOnly": false,
"name": "visit_first",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "1679133100716"
},
{
"domain": ".semrush.com",
"expirationDate": 1710174391.430467,
"hostOnly": false,
"httpOnly": false,
"name": "__insp_norec_howoften",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": null,
"value": "true"
},
{
"domain": "www.semrush.com",
"expirationDate": 1710140973,
"hostOnly": true,
"httpOnly": false,
"name": "sa-user-id",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "s%253A0-ab4c2f24-7d73-46a5-7fe9-13eb11417501.GpOwfUl3tKG%252BioSw2t5v%252FDqvTg6s2JXXrGdGUQL3x8M"
},
{
"domain": ".semrush.com",
"expirationDate": 1712919844,
"hostOnly": false,
"httpOnly": false,
"name": "_uetvid",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "b0f4681097c211ed94f4197abace80db"
},
{
"domain": ".www.semrush.com",
"expirationDate": 1708613850.453209,
"hostOnly": false,
"httpOnly": false,
"name": "csrftoken",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "tZi14OZMxmx1IsS7Dgb6RWbmZkbQ0fcAkoMCB5Iev1voP59QaaNm5T8xENwj7wIk"
},
{
"domain": ".semrush.com",
"expirationDate": 1710759843,
"hostOnly": false,
"httpOnly": false,
"name": "_ga_BPNLXP3JQG",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "GS1.1.1679223812.6.1.1679223843.29.0.0"
},
{
"domain": ".semrush.com",
"expirationDate": 1689406361,
"hostOnly": false,
"httpOnly": false,
"name": "irclickid",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "TDj3qwVxWz-iUBvWMD2gY0m5UkARMoUNaW08xA0"
},
{
"domain": ".semrush.com",
"expirationDate": 1710174390.951664,
"hostOnly": false,
"httpOnly": false,
"name": "__insp_nv",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": null,
"value": "true"
},
{
"domain": ".semrush.com",
"expirationDate": 1710174390.950514,
"hostOnly": false,
"httpOnly": false,
"name": "__insp_slim",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": null,
"value": "1678638390950"
},
{
"domain": ".semrush.com",
"expirationDate": 1710174390.953216,
"hostOnly": false,
"httpOnly": false,
"name": "__insp_targlpu",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": null,
"value": "aHR0cHM6Ly93d3cuc2VtcnVzaC5jb20vYmlsbGluZy1hZG1pbi9wcm9maWxlL3N1YnNjcmlwdGlvbg%3D%3D"
},
{
"domain": ".semrush.com",
"expirationDate": 1710174390.950314,
"hostOnly": false,
"httpOnly": false,
"name": "__insp_wid",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": null,
"value": "861992209"
},
{
"domain": ".semrush.com",
"expirationDate": 1710759843,
"hostOnly": false,
"httpOnly": false,
"name": "_ga",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "GA1.1.311764306.1679133109"
},
{
"domain": ".semrush.com",
"expirationDate": 1686909109,
"hostOnly": false,
"httpOnly": false,
"name": "_gcl_au",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "1.1.1418327698.1679133109"
},
{
"domain": ".semrush.com",
"expirationDate": 1679310243,
"hostOnly": false,
"httpOnly": false,
"name": "_gid",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "GA1.2.1649825765.1679133109"
},
{
"domain": ".semrush.com",
"expirationDate": 1710759842,
"hostOnly": false,
"httpOnly": false,
"name": "cookiehub",
"path": "/",
"sameSite": "lax",
"secure": false,
"session": false,
"storeId": null,
"value": "eyJhbnN3ZXJlZCI6ZmFsc2UsInByZWNvbnNlbnQiOnRydWUsInJldmlzaW9uIjoxLCJkbnQiOmZhbHNlLCJhbGxvd1NhbGUiOnRydWUsImltcGxpY3QiOnRydWUsInJlZ2lvbiI6IkcwIiwidG9rZW4iOiJJS3R2VGxKenIwa2R0NDV5Y3R5THdtNDJKTWx3NVJ1ZFF1eVNOQ3Y4bnNMZkRGRXBWbGJheGdQRnBwdWRHUUloIiwidGltZXN0YW1wIjoiMjAyMy0wMy0xOFQwOTo1MTo0OC41NjRaIiwiY2F0ZWdvcmllcyI6W3siY2lkIjoxLCJpZCI6Im5lY2Vzc2FyeSIsInZhbHVlIjp0cnVlLCJwcmVjb25zZW50Ijp0cnVlLCJ0cmFja2luZyI6ZmFsc2UsImRlZmF1bHQiOnRydWUsImZpcmVkIjpmYWxzZX0seyJjaWQiOjIsImlkIjoicHJlZmVyZW5jZXMiLCJ2YWx1ZSI6dHJ1ZSwicHJlY29uc2VudCI6dHJ1ZSwidHJhY2tpbmciOmZhbHNlLCJkZWZhdWx0IjpmYWxzZSwiZmlyZWQiOmZhbHNlfSx7ImNpZCI6MywiaWQiOiJhbmFseXRpY3MiLCJ2YWx1ZSI6dHJ1ZSwicHJlY29uc2VudCI6dHJ1ZSwidHJhY2tpbmciOnRydWUsImRlZmF1bHQiOmZhbHNlLCJmaXJlZCI6ZmFsc2V9LHsiY2lkIjo0LCJpZCI6Im1hcmtldGluZyIsInZhbHVlIjp0cnVlLCJwcmVjb25zZW50Ijp0cnVlLCJ0cmFja2luZyI6dHJ1ZSwiZGVmYXVsdCI6ZmFsc2UsImZpcmVkIjpmYWxzZX1dfQ=="
},
{
"domain": ".semrush.com",
"expirationDate": 1681630352,
"hostOnly": false,
"httpOnly": false,
"name": "ga_exp_c41234be21bd4796bbf8e763",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "0"
},
{
"domain": ".semrush.com",
"expirationDate": 1679929092.024743,
"hostOnly": false,
"httpOnly": false,
"name": "ga_exp_ef5a1bca663a467d802f4249",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "1"
},
{
"domain": ".semrush.com",
"expirationDate": 1679290895,
"hostOnly": false,
"httpOnly": false,
"name": "PHPSESSID",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "406a550a84f97e5096aa18efda0fd4ea"
},
{
"domain": ".www.semrush.com",
"expirationDate": 1710669114,
"hostOnly": false,
"httpOnly": false,
"name": "sa-user-id-v2",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "s%253A-p2Gn46JSVZ8138irI9KTHRHi1k.Rp0l5gy%252FTi1Gp4QxJG0j8wsLrrzm75BaGb2fTSVknWM"
},
{
"domain": ".semrush.com",
"expirationDate": 1679290926.711403,
"hostOnly": false,
"httpOnly": true,
"name": "SSO-JWT",
"path": "/",
"sameSite": null,
"secure": true,
"session": false,
"storeId": null,
"value": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0MDZhNTUwYTg0Zjk3ZTUwOTZhYTE4ZWZkYTBmZDRlYSIsImlhdCI6MTY3OTIwNDUxOCwiaXNzIjoic3NvIiwidWlkIjoxNDcxMjg5N30.WqwuQmmlqE3U3t1FW2Lja6DUiH77ehw3Cu2PSbIAa9Qwu40nX1OdYzyWT-Dmfca-4-z6GfP3mNbAdZaWzRgzcg"
},
{
"domain": ".semrush.com",
"expirationDate": 1710174373,
"hostOnly": false,
"httpOnly": false,
"name": "userdata",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "%7B%22tz%22%3A%22GMT-4%22%2C%22ol%22%3A%22en%22%7D"
},
{
"domain": "www.semrush.com",
"expirationDate": 1710174388,
"hostOnly": true,
"httpOnly": false,
"name": "utz",
"path": "/",
"sameSite": null,
"secure": false,
"session": false,
"storeId": null,
"value": "America%2FNew_York"
}
]