How to send an email with an attachment using SMTP

Xamarin Logo

How to send an email with an attachment in Xamarin

First and foremost, allow me note that 80% of the answers I found on the internet for this particular task is worthless. A bunch of losers give mystical and cryptic answers so their answers can be counted towards their invisible miserable points. If it were up to me, I would single hand-idly hunt those vague sons of bitches down and not let them EVER post anything on the internet.

Here’s the simple example of sending an email with attachment using SMTP. I took a sample test.png picture and added it to the Drawable folder.

Note: If you are using your own gmail account to test this, you need to alter settings in your gmail account to do so.

Essentially, you are letting this app access your gmail account, as a result in your account settings you need to turn on the feature with enables that to happen.
Go into your gmail “My Account” –> “Connected apps & sites” –> and turn ON the “Allowing less secure apps to access your account” option.

Read more here: https://support.google.com/accounts/answer/6010255?hl=en

 

Leave a Reply