0
votes

I want to send email over google/gmail from my mvc application after oauth.

I am using mvc 4. My application will ask for authorize this app for oauth. Then I want to send email to other user from the application.

If you help me through code and step to do, that will be great.

2

2 Answers

0
votes

You can Use Postal which is very handy and easy to use ,to send emails

Controller

dynamic email = new Email("Email");
email.To = UserName;
email.FirstName = FName;
email.LastName = LName;
email.Send();

Then in your View Email

@{
Layout = null;
}

To: @ViewBag.To
From: Example [email protected]
Subject: blah blah

Hello @ViewBag.FirstName,

Your Text.........
This is auto generated email please do not reply.

Edited

Please add your smtp credentials in web.config

<system.net>
<mailSettings>
  <smtp deliveryMethod="Network" from="[email protected]">
    <network defaultCredentials="false" host="smtp.gmail.com" port="587" enableSsl="true" userName="[email protected]" password="1234567" />
  </smtp>
</mailSettings>
</system.net>

This is very simple. Just give a try Hope this helps!

0
votes

I have made lots of work out. and Finally.... I have resolved my problem.

In C#, there is no any direct SMTP and Oauth lib. So you need to work manually.

Make Oauth2 access using api and get access "offline".

Then Refer this link SMTP and Oauth