public SendRawEmail ( SendRawEmailRequest request ) : SendRawEmailResponse | ||
request | SendRawEmailRequest | Container for the necessary parameters to execute the SendRawEmail service method. |
return | SendRawEmailResponse |
public static void SESSendRawEmail() { #region SESSendRawEmail // using System.IO; var sesClient = new AmazonSimpleEmailServiceClient(); var stream = new MemoryStream( Encoding.UTF8.GetBytes("From: [email protected]\n" + "To: [email protected]\n" + "Subject: You're invited to the meeting\n" + "Content-Type: text/plain\n\n" + "Please join us Monday at 7:00 PM.") ); var raw = new RawMessage { Data = stream }; var to = new List<string>() { "*****@*****.**" }; var from = "*****@*****.**"; var request = new SendRawEmailRequest { Destinations = to, RawMessage = raw, Source = from }; sesClient.SendRawEmail(request); #endregion }
public static string sendInvEmail(string email, string subject, string msg, string attach1, string attach2) { try { Amazon.SimpleEmail.AmazonSimpleEmailServiceConfig config = new Amazon.SimpleEmail.AmazonSimpleEmailServiceConfig(); config.RegionEndpoint = Amazon.RegionEndpoint.USEast1; Amazon.SimpleEmail.AmazonSimpleEmailServiceClient client = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient("AKIAI6NU4VLLI32AI2UA", Cryptography.Decrypt("NdL0xWLhvbF6pvu3hw1FtluhPmUc1jAuWKgj6mb4V89KztEq6MjEhQoiCPLVv4y9"), config); var stream = new MemoryStream(); MimeMessage objMessage = new MimeMessage(); string[] emls = email.Split(','); foreach (string eml in emls) { objMessage.To.Add(new MailboxAddress(string.Empty, eml)); } objMessage.From.Add(new MailboxAddress("InfnIT Invoice", "*****@*****.**")); objMessage.Subject = subject; BodyBuilder emailBodyObj = new BodyBuilder(); emailBodyObj.HtmlBody = msg; emailBodyObj.Attachments.Add(attach1); emailBodyObj.Attachments.Add(attach2); objMessage.Body = emailBodyObj.ToMessageBody(); objMessage.WriteTo(stream); Amazon.SimpleEmail.Model.SendRawEmailRequest mailObj = new Amazon.SimpleEmail.Model.SendRawEmailRequest(new RawMessage(stream)); SendRawEmailResponse response = client.SendRawEmail(mailObj); string res = response.MessageId; System.Net.Mail.MailMessage aMessage = new System.Net.Mail.MailMessage(); aMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "InfnIT Invoice"); //aMessage.To.Add(email); //aMessage.ReplyTo = new System.Net.Mail.MailAddress("*****@*****.**"); //aMessage.Subject = subject; //System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(msg, System.Text.Encoding.UTF8, "text/html"); //aMessage.IsBodyHtml = true; //aMessage.BodyEncoding = System.Text.Encoding.UTF8; //aMessage.Attachments.Add(new System.Net.Mail.Attachment(attach1)); //aMessage.Attachments.Add(new System.Net.Mail.Attachment(attach2)); //aMessage.AlternateViews.Add(htmlView); //System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient(); //mailClient.Host = "smtp.gmail.com"; //mailClient.Port = 587; //mailClient.EnableSsl = true; //mailClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "m4iling2"); //mailClient.Send(aMessage); return("success");//downloadCfdi += "<p>Correo enviado"; } catch (Exception ex) { return(ex.Message); //downloadCfdi += "<p><i class=\"w3-red\">No se pudo enviar el correo: +" + ex.Message + "</i>"; } }
public static void Send(string from, string to, string bcc, string subject, string body) { using (var client = new AmazonSimpleEmailServiceClient(Settings.AccessKey, Settings.Secret, RegionEndpoint.USWest2)) { var request = new SendRawEmailRequest { Source = from, Destinations = new List<string> { to, bcc }, RawMessage = CreateMessage(from, to, bcc, subject, body) }; client.SendRawEmail(request); } }
static void Main(string[] args) { Console.WriteLine("Press any key to send mail!"); Console.ReadKey(); //Getting AWS credentials from App.config //note: see the app.config to get a example var credentials = new EnvironmentAWSCredentials(); //Client SES instantiated var client = new AmazonSimpleEmailServiceClient(credentials, RegionEndpoint.USEast1); var mimeMessage = new MimeMessage(); //Add sender e-mail address //Note: this e-mail address must to be allowed and checked by AWS SES mimeMessage.From.Add(new MailboxAddress("Test Sender", "*****@*****.**")); //Add e-mail address destiny mimeMessage.To.Add(new MailboxAddress("Joel", "*****@*****.**")); mimeMessage.Subject = "Test"; //Getting attachment stream var fileBytes = File.ReadAllBytes(@"C:\anyfile.pdf"); var bodyBuilder = new BodyBuilder(); bodyBuilder.TextBody = "Testing the body message"; //You must to inform the mime-type of the attachment and his name bodyBuilder.Attachments.Add("AnyAttachment.pdf", fileBytes, new ContentType("application", "pdf")); mimeMessage.Body = bodyBuilder.ToMessageBody(); //Map MimeMessage to MemoryStream, that is what SenRawEmailRequest accepts var rawMessage = new MemoryStream(); mimeMessage.WriteTo(rawMessage); client.SendRawEmail(new SendRawEmailRequest(new RawMessage(rawMessage))); Console.WriteLine("Email Sended"); Console.ReadKey(); }
public static void SendVerificationEmail(string emailaddress, string validation_guid) { const string VERIFICATION_DOMAIN = "https://nzixo03fx1.execute-api.us-west-2.amazonaws.com/prod/emailvalidation?verificationstring="; //TODO: Move this to our domain name prior to launch const string FROM = "*****@*****.**"; //TODO: Change to real domain name const string SUBJECT = "Please verify your email address"; string TO = emailaddress; string mBase64EncodedGuid = Convert.ToBase64String(Encoding.UTF8.GetBytes(emailaddress + ":" + validation_guid)); var message = new MimeMessage(); message.From.Add(new MailboxAddress("GEM CARRY EMAIL VERIFICATION", FROM)); message.To.Add(new MailboxAddress("New Gamer", TO)); message.Subject = SUBJECT; var builder = new BodyBuilder(); builder.TextBody = string.Format("To activate your account, please click the following link to verifiy your email address {0}{1}", VERIFICATION_DOMAIN, mBase64EncodedGuid); builder.HtmlBody = string.Format("To activate your account, please click <a href={0}{1}> here</a> to verify your email address.",VERIFICATION_DOMAIN,mBase64EncodedGuid); message.Body = builder.ToMessageBody(); var stream = new MemoryStream(); message.WriteTo(stream); try { AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(); var request = new SendRawEmailRequest { RawMessage = new RawMessage { Data = stream } }; client.SendRawEmail(request); #if DEBUG logger.WriteLog(GameLogger.LogLevel.Debug, string.Format("Generating Validation Email for {0}.", emailaddress)); #endif // DEBUG } catch (Exception ex) { logger.WriteLog(GameLogger.LogLevel.Error, ex.Message.ToString()); } }