Created
January 19, 2020 15:43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net.Mail; | |
using Xamarin.Forms; | |
namespace XamarinFormsEmail | |
{ | |
public partial class MainPage : ContentPage | |
{ | |
public MainPage() | |
{ | |
InitializeComponent(); | |
} | |
void btnSend_Clicked(object sender, System.EventArgs e) | |
{ | |
try{ | |
MailMessage mail = new MailMessage(); | |
SmtpClient SmtpServer = new SmtpClient("email-smtp.us-east-1.amazonaws.com"); | |
mail.From = new MailAddress("susairajs18@gmail.com"); | |
mail.To.Add(txtTo.Text.ToLower()); | |
mail.Subject = txtSubject.Text; | |
mail.Body = txtBody.Text; | |
SmtpServer.Port = 587; | |
SmtpServer.Host = "email-smtp.us-east-1.amazonaws.com"; | |
SmtpServer.EnableSsl = true; | |
SmtpServer.UseDefaultCredentials = false; | |
SmtpServer.Credentials = new System.Net.NetworkCredential("AKI*****2LUH6IA", "AnH9IL********eRL5xjGa2LsmDDbozvsTx"); | |
SmtpServer.Send(mail); | |
} | |
catch(Exception ex) | |
{ | |
DisplayAlert("Faild", ex.Message, "OK"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment