---
title: "Sending email in .NET through Gmail"  
description: "Sending email in .NET through Gmail"  
author: "Anonymous User"  
published: 2013-05-29  
updated: 2013-05-29  
canonical: https://www.mindstick.com/forum/931/sending-email-in-dot-net-through-gmail  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Sending email in .NET through Gmail

Hi Everyone!\
[Instead of](https://www.mindstick.com/articles/330/triggers-in-sql-server) relying on my [host](https://yourviews.mindstick.com/view/85456/foreign-direct-investment-fdi-and-its-impacts-on-host-countries) to [send email](https://www.mindstick.com/interview/2006/how-can-you-send-an-email-message-from-an-asp-dot-net-web-page), I was [thinking](https://www.mindstick.com/blog/11889/how-to-change-your-thinking-paradigm) of sending the [messages](https://www.mindstick.com/news/4166/google-rolling-out-gemini-extensions-for-messages-whatsapp-and-spotify) though my [Gmail account](https://answers.mindstick.com/qa/50937/how-to-set-up-gmail-account-on-your-iphone-6s). The emails are personalized emails to the bands I play on my show. Is it possible to do?\
Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

Hi Jayprakash!\
Be sure to use System.Net.Mail, not the deprecated System.Web.Mail. Doing SSL with System.Web.Mail is a gross mess of hacky extensions.\
using System.Net;using System.Net.Mail;\
var fromAddress = new MailAddress("from@[gmail](https://www.mindstick.com/articles/157262/why-to-go-with-the-gmail-signup-procedure).com", "From Name");var toAddress = new MailAddress("to@example.com", "To Name");const string fromPassword = "fromPassword";const string subject = "Subject";const string body = "Body";\
var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) };using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }){ smtp.Send(message);}


---

Original Source: https://www.mindstick.com/forum/931/sending-email-in-dot-net-through-gmail

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
