question

37349445 avatar image
0 Votes"
37349445 asked LanHuang-MSFT answered

Using Gmail And Web Api To Send Email Failing

I am currently busy with a Web Api allication that sends emails using the credentials from my gmail account. I have the following in my webconfig file

 <mailSettings>
       <smtp from = "mygmailemailaddress" >
         <network host="smtp.gmail.com"
                 port="587"
                 userName="mygmailemailaddress"
                 password="myaccountpassword"
                 enableSsl="true" />
       </smtp>
     </mailSettings>

However, this keeps failing, what is the issue and how do I fix it?


dotnet-aspnet-webapi
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LanHuang-MSFT avatar image
0 Votes"
LanHuang-MSFT answered

Hi @37349445,
Could you post us the details of your error message?
The reason of your problems I think there are these:
1. Maybe the name or password isn't right. You can check whether the user name and password are correct. When sending email via code, you need to pass the full email address as the username.
2. Maybe Gmail has blocked your application, you need to modify the settings of the less secure application and open the access to the less secure application.

Best regards,
Lan Huang


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.