public SendEmail ( SendEmailRequest request ) : SendEmailResponse | ||
request | SendEmailRequest | Container for the necessary parameters to execute the SendEmail service method. |
return | SendEmailResponse |
static void Main(string[] args) { if (CheckRequiredFields()) { using (var client = new AmazonSimpleEmailServiceClient(RegionEndpoint.USEast1)) { var sendRequest = new SendEmailRequest { Source = senderAddress, Destination = new Destination { ToAddresses = new List<string> { receiverAddress } }, Message = new Message { Subject = new Content("Sample Mail using SES"), Body = new Body { Text = new Content("Sample message content.") } } }; try { Console.WriteLine("Sending email using AWS SES..."); var response = client.SendEmail(sendRequest); Console.WriteLine("The email was sent successfully."); } catch (Exception ex) { Console.WriteLine("The email was not sent."); Console.WriteLine("Error message: " + ex.Message); } } } Console.Write("Press any key to continue..."); Console.ReadKey(); }
public void SendEmails(AmazonSimpleEmailServiceClient aClient) { IEnumerable<EmailJob> myEmailsToSendOut = theEmailRepo.GetEmailJobsToBeSent(); if (myEmailsToSendOut.Count<EmailJob>() != 0) { ConsoleMessageWithDate("Have to send emails: " + myEmailsToSendOut.Count<EmailJob>()); foreach (EmailJob myEmailJob in myEmailsToSendOut) { SendEmailRequest myRequest = new SendEmailRequest(); List<string> mySendTo = new List<string>(); mySendTo.Add(myEmailJob.ToEmail); Content mySubject = new Content(myEmailJob.Subject); Body myBody = new Body(); myBody.Html = new Content(myEmailJob.Body); myRequest.Destination = new Destination(mySendTo); myRequest.Message = new Message(mySubject, myBody); myRequest.Source = myEmailJob.FromEmail; //Change flag with the send in between so we can track if shit happened theEmailRepo.MarkEmailPresentToTrue(myEmailJob.Id); aClient.SendEmail(myRequest); theEmailRepo.MarkEmailPostsentToTrue(myEmailJob.Id); ConsoleMessageWithDate("A " + myEmailJob.EmailDescription + " has been sent to " + myEmailJob.ToEmail + " from " + myEmailJob.FromEmail); } } else { ConsoleMessageWithDate("No emails required to be sent out"); } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button> (Resource.Id.myButton); button.Click += delegate { const string ACCESS_KEY = ""; const string SECRET_KEY = ""; const string YOUR_EMAIL = ""; AmazonSimpleEmailServiceClient sesClient = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient (ACCESS_KEY, SECRET_KEY, Amazon.RegionEndpoint.USEast1); var Name = FindViewById<EditText>(Resource.Id.name); var Rating = FindViewById<RatingBar>(Resource.Id.ratingBar); var Comments = FindViewById<EditText>(Resource.Id.comments); var messageBody = new Amazon.SimpleEmail.Model.Content (String.Format("Rating: {0}\n\nComments:\n{1}", Rating.Selected, Comments.Text)); var body = new Amazon.SimpleEmail.Model.Body (messageBody); var subject = new Amazon.SimpleEmail.Model.Content (String.Format ("Feedback from {0}", Name.Text)); var message = new Amazon.SimpleEmail.Model.Message (subject, body); var destination = new Amazon.SimpleEmail.Model.Destination (new System.Collections.Generic.List<string> (){ YOUR_EMAIL }); var sendEmailRequest = new Amazon.SimpleEmail.Model.SendEmailRequest (YOUR_EMAIL, destination, message); sesClient.SendEmail (sendEmailRequest); }; }
public static bool SendEmailWithAmazone(string FROM, string TO, string SUBJECT, string BODY, string AWSAccessKey, string AWSSecrectKey, string NameSender) { string Name = NameSender; Destination destination = new Destination().WithToAddresses(new List<string>() { TO }); // Create the subject and body of the message. Amazon.SimpleEmail.Model.Content subject = new Amazon.SimpleEmail.Model.Content().WithData(SUBJECT); Amazon.SimpleEmail.Model.Content textBody = new Amazon.SimpleEmail.Model.Content().WithData(BODY); Body body = new Body().WithHtml(textBody); // Create a message with the specified subject and body. Message message = new Message().WithSubject(subject).WithBody(body); string Fr = String.Format("{0}<{1}>", Name, FROM); SendEmailRequest request = new SendEmailRequest().WithSource(Fr).WithDestination(destination).WithMessage(message); using (AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(AWSAccessKey, AWSSecrectKey)) { // Send the email. try { client.SendEmail(request); return true; } catch (Exception) { return false; } } }
public static void SESSendEmail() { #region SESSendEmail var sesClient = new AmazonSimpleEmailServiceClient(); var dest = new Destination { ToAddresses = new List<string>() { "*****@*****.**" }, CcAddresses = new List<string>() { "*****@*****.**" } }; var from = "*****@*****.**"; var subject = new Content("You're invited to the meeting"); var body = new Body(new Content("Please join us Monday at 7:00 PM.")); var msg = new Message(subject, body); var request = new SendEmailRequest { Destination = dest, Message = msg, Source = from }; sesClient.SendEmail(request); #endregion }
public void Send(string name, string replyTo, string messageBody) { var destination = new Destination() { ToAddresses = new List<string>() { TO } }; var subject = new Content(SUBJECT); var body = new Body() { Html = new Content(string.Format(BODY, name, messageBody)) }; var message = new Message(subject, body); var request = new SendEmailRequest(FROM, destination, message); request.ReplyToAddresses = new List<string> { replyTo }; var region = Amazon.RegionEndpoint.USEast1; using (var client = new AmazonSimpleEmailServiceClient(region)) { try { client.SendEmail(request); } catch(Exception ex) { Console.WriteLine(ex.ToString()); } } }
public Task<bool> SendEmail(string to, string subject, string htmlBody) { if (string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(htmlBody) || !to.IsEmail()) return Task.FromResult(false); var destination = new Destination { ToAddresses = new List<string> { to } }; var contentSubject = new Content { Charset = Encoding.UTF8.EncodingName, Data = subject }; var contentBody = new Content { Charset = Encoding.UTF8.EncodingName, Data = htmlBody }; var body = new Body { Html = contentBody }; var message = new Message { Body = body, Subject = contentSubject }; var request = new SendEmailRequest { Source = FROM_EMAIL, Destination = destination, Message = message }; var client = new AmazonSimpleEmailServiceClient(); try { client.SendEmail(request); } catch (Exception ex) { return Task.FromResult(false); } return Task.FromResult(true); }
//From E-mail address must be verified through Amazon /// <param name="AWSAccessKey">public key associated with our Amazon Account</param> /// <param name="AWSSecretKey">private key associated with our Amazon Account</param> /// <param name="ToEmail">Who do you want to send the E-mail to, seperate multiple addresses with a comma</param> /// <param name="FromEmail">Who is the e-mail from, this must be a verified e-mail address through Amazon</param> /// <param name="Subject">Subject of e-mail</param> /// <param name="Content">Text for e-mail</param> public void SendEmail(string AWSAccessKey, string AWSSecretKey, string ToEmail, string FromEmail, string Subject, string Content) { Amazon.SimpleEmail.AmazonSimpleEmailServiceClient client = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient(AWSAccessKey, AWSSecretKey); SendEmailRequest em = new SendEmailRequest() .WithDestination(new Destination() { BccAddresses = new List<String>() { ToEmail } }) .WithSource(FromEmail) .WithMessage(new Message(new Content(Subject), new Body().WithText(new Content(Content)))); SendEmailResponse response = client.SendEmail(em); }
public void SendEmail(string to, string subject, string bodyText, string bodyHtml) { using (var client = new AmazonSimpleEmailServiceClient(RegionEndpoint.EUWest1)) { var content = new Content(subject); var body = new Body{Html = new Content(bodyHtml), Text = new Content(bodyText)}; var message = new Message(content, body); var destination = new Destination(new List<string> {to}); var sendEmailRequest = new SendEmailRequest(FromEmail, destination, message); client.SendEmail(sendEmailRequest); } }
protected void Page_Load(object sender, EventArgs e) { AmazonSimpleEmailServiceConfig amConfig = new AmazonSimpleEmailServiceConfig(); amConfig.UseSecureStringForAwsSecretKey = false; AmazonSimpleEmailServiceClient amzClient = new AmazonSimpleEmailServiceClient(ConfigurationManager.AppSettings["AWSAccessKey"].ToString(), ConfigurationManager.AppSettings["AWSSecretKey"].ToString(),amConfig); ArrayList to = new ArrayList(); //ADD AS TO 50 emails per one sending method////////////////////// //to.Add("*****@*****.**"); //to.Add("*****@*****.**"); to.Add("*****@*****.**"); to.Add("*****@*****.**"); to.Add("*****@*****.**"); to.Add("*****@*****.**"); to.Add("*****@*****.**"); to.Add("*****@*****.**"); Destination dest = new Destination(); dest.WithToAddresses((string[])to.ToArray(typeof(string))); //dest.WithToAddresses((string[])to.ToArray(typeof(string))); string body = "INSERT HTML BODY HERE"; string subject = "INSERT EMAIL SUBJECT HERE"; Body bdy = new Body(); bdy.Html = new Amazon.SimpleEmail.Model.Content(body); Amazon.SimpleEmail.Model.Content title = new Amazon.SimpleEmail.Model.Content(subject); Message message = new Message(title, bdy); //VerifyEmailAddressRequest veaRequest = new VerifyEmailAddressRequest(); // veaRequest.EmailAddress = "*****@*****.**"; // VerifyEmailAddressResponse veaResponse = amzClient.VerifyEmailAddress(veaRequest); SendEmailRequest ser = new SendEmailRequest("*****@*****.**", dest, message); ser.WithReturnPath("*****@*****.**"); SendEmailResponse seResponse = amzClient.SendEmail(ser); SendEmailResult seResult = seResponse.SendEmailResult; //GetSendStatisticsRequest request=new GetSendStatisticsRequest(); //GetSendStatisticsResponse obj = amzClient.GetSendStatistics(request); //List<SendDataPoint> sdata = new List<SendDataPoint>(); //sdata=obj.GetSendStatisticsResult.SendDataPoints; //Int64 sentCount = 0,BounceCount=0,DeleveryAttempts=0; //for (int i = 0; i < sdata.Count; i++) //{ // BounceCount = BounceCount +sdata[i].Bounces; // DeleveryAttempts = DeleveryAttempts + sdata[i].DeliveryAttempts; //} //sentCount = DeleveryAttempts - BounceCount; }
public async Task Send(Indulgence indulgence, string indulgenceFilePath) { service = new AmazonSimpleEmailServiceClient( ConfigurationManager.AppSettings["awsAccessKeyId"], ConfigurationManager.AppSettings["awsAccessSecret"]); SendEmailRequest request = new SendEmailRequest(); request.Destination = BuildDestination(); request.Message=BuildMessage(indulgence); request.Source="*****@*****.**"; var response = service.SendEmail(request); }
public async Task Send(Indulgence indulgence, string indulgenceFilePath) { service = new AmazonSimpleEmailServiceClient( ConfigurationManager.AppSettings["awsAccessKeyId"], ConfigurationManager.AppSettings["awsAccessSecret"]); SendEmailRequest request = new SendEmailRequest(); request.Destination = BuildDestination(); request.Message = BuildMessage(indulgence); request.Source = "*****@*****.**"; var response = service.SendEmail(request); }
/// <summary> /// Sends an email with opt out option /// </summary> /// <param name="fromEmail"></param> /// <param name="toEmail"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <returns></returns> public bool SendMail(string fromEmail, string toEmail, string subject, string body) { if (string.IsNullOrEmpty(toEmail) || string.IsNullOrEmpty(fromEmail) || string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(body)) return false; try { toEmail = toEmail.Trim(); fromEmail = fromEmail.Trim(); var amzClient = new AmazonSimpleEmailServiceClient( AmazonCloudConfigs.AmazonAccessKey, AmazonCloudConfigs.AmazonSecretKey, RegionEndpoint.USEast1); var dest = new Destination(); dest.ToAddresses.Add(toEmail); body = body + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + "----------------------------" + Environment.NewLine + "Unsubscribe From Email: " + // TODO: LOCALIZE Environment.NewLine + GeneralConfigs.EmailSettingsURL + Environment.NewLine; var bdy = new Body {Text = new Content(body)}; var title = new Content(subject); var message = new Message(title, bdy); fromEmail = string.Format("{0} <{1}>", GeneralConfigs.SiteName, fromEmail); var ser = new SendEmailRequest(fromEmail, dest, message); var response = amzClient.SendEmail(ser); return true; } catch (Exception ex) { return false; } }
void HandleTouchUpInside (object sender, EventArgs e) { const string ACCESS_KEY = ""; const string SECRET_KEY = ""; const string YOUR_EMAIL = ""; AmazonSimpleEmailServiceClient sesClient = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient (ACCESS_KEY, SECRET_KEY, Amazon.RegionEndpoint.USEast1); var messageBody = new Amazon.SimpleEmail.Model.Content (String.Format("Rating: {0}\n\nComments:\n{1}", Rating.SelectedSegment, Comments.Text)); var body = new Amazon.SimpleEmail.Model.Body (messageBody); var subject = new Amazon.SimpleEmail.Model.Content (String.Format ("Feedback from {0}", Name.Text)); var message = new Amazon.SimpleEmail.Model.Message (subject, body); var destination = new Amazon.SimpleEmail.Model.Destination (new System.Collections.Generic.List<string> (){ YOUR_EMAIL }); var sendEmailRequest = new Amazon.SimpleEmail.Model.SendEmailRequest (YOUR_EMAIL, destination, message); sesClient.SendEmail (sendEmailRequest); }
public static void SendEmailRegisterInterest(string emailContentPath, string email) { var recipientEmail = SetRecipientEmail(email); // Send email after adding user to interested people var bodyContent = new Content(System.IO.File.ReadAllText(emailContentPath)); // create email request var request = new SendEmailRequest() .WithDestination(new Destination(new List<string> { recipientEmail })) .WithSource("*****@*****.**") .WithReturnPath("*****@*****.**") .WithMessage(new Message() .WithSubject(new Content("Thanks for joining the GreenMoney waiting list")) .WithBody(new Body().WithHtml(bodyContent)) ); // send it var client = new AmazonSimpleEmailServiceClient("AKIAIDP5FFSCJUHHC4QA", "NKAzwbtwwhvKuQZj2t6OXxOhaOEuaBYh3E34Jxbs"); client.SendEmail(request); }
public Task<string> Send(IEnumerable<string> to, IEnumerable<string> cc, string from, string title, string htmlBody, string textBody) { AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(_accessKey, _secretKey); Destination destination = new Destination(); destination.ToAddresses = to.ToList(); Content subject = new Content(title); Body bodyContent = new Body() { Html = htmlBody == null ? null : new Content(htmlBody), Text = textBody == null ? null : new Content(textBody) }; Message message = new Message(subject, bodyContent); SendEmailRequest request = new SendEmailRequest { ReplyToAddresses = new List<string>() {@from}, Destination = destination, Message = message }; SendEmailResponse response = client.SendEmail(request); return Task.FromResult(response.MessageId); }
public static void SendEmailAdditionalMemberInvitation(string email, string inviterName, string url) { var bodyContent = "Your household member " + inviterName + " sent you this <a href='" + url + "'>link</a> to join Green Money."; var recipientEmail = SetRecipientEmail(email); // create email request var request = new SendEmailRequest() .WithDestination(new Destination(new List<string> { recipientEmail })) .WithSource("*****@*****.**") .WithReturnPath("*****@*****.**") .WithMessage(new Message() .WithSubject(new Content("GreenMoney. Household member invitation")) .WithBody(new Body().WithHtml(new Content(bodyContent))) ); //send it var client = new AmazonSimpleEmailServiceClient("AKIAIDP5FFSCJUHHC4QA", "NKAzwbtwwhvKuQZj2t6OXxOhaOEuaBYh3E34Jxbs"); client.SendEmail(request); }
public static bool SendEmailWithAmazone(string FROM, string TO, string SUBJECT, string BODY, string AWSAccessKey, string AWSSecrectKey, string NameSender) { log4net.ILog log = log4net.LogManager.GetLogger("ErrorRollingLogFileAppender"); try { string Name = NameSender; Destination destination = new Destination().WithToAddresses(new List<string>() { TO }); // Create the subject and body of the message. Amazon.SimpleEmail.Model.Content subject = new Amazon.SimpleEmail.Model.Content().WithData(SUBJECT); Amazon.SimpleEmail.Model.Content textBody = new Amazon.SimpleEmail.Model.Content().WithData(BODY); Body body = new Body().WithHtml(textBody); // Create a message with the specified subject and body. Message message = new Message().WithSubject(subject).WithBody(body); string Fr = String.Format("{0}<{1}>", Name, FROM); SendEmailRequest request = new SendEmailRequest().WithSource(Fr).WithDestination(destination).WithMessage(message); using (AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(AWSAccessKey, AWSSecrectKey)) { // Send the email. try { client.SendEmail(request); return true; } catch (Exception e) { log.Error("ProcessSendEmail-callSendBulkMail_BySubGroup" + e); return false; } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); log.Error("ProcessSendEmail-callSendBulkMail_BySubGroup" + ex);return false; } }
protected void Page_Load(object sender, EventArgs e) { AmazonSimpleEmailServiceConfig amConfig = new AmazonSimpleEmailServiceConfig(); amConfig.UseSecureStringForAwsSecretKey = false; AmazonSimpleEmailServiceClient amzClient = new AmazonSimpleEmailServiceClient(ConfigurationManager.AppSettings["AWSAccessKey"].ToString(), ConfigurationManager.AppSettings["AWSSecretKey"].ToString(), amConfig); ArrayList to = new ArrayList(); to.Add("*****@*****.**"); //to.Add("*****@*****.**"); for (int i = 0; i < to.Count; i++) { Destination dest = new Destination(); dest.WithToAddresses(to[i].ToString()); string body = "Hello this is testing AWS"; string subject = "Test AWS"; Body bdy = new Body(); bdy.Html = new Amazon.SimpleEmail.Model.Content(body); Amazon.SimpleEmail.Model.Content title = new Amazon.SimpleEmail.Model.Content(subject); Message message = new Message(title, bdy); SendEmailRequest ser = new SendEmailRequest("*****@*****.**", dest, message); ser.WithReturnPath("*****@*****.**"); SendEmailResponse seResponse = amzClient.SendEmail(ser); SendEmailResult seResult = seResponse.SendEmailResult; } //GetSendStatisticsRequest request = new GetSendStatisticsRequest(); //GetSendStatisticsResponse obj = amzClient.GetSendStatistics(request); //List<SendDataPoint> sdata = new List<SendDataPoint>(); //sdata = obj.GetSendStatisticsResult.SendDataPoints; //Int64 sentCount = 0, BounceCount = 0, DeleveryAttempts = 0; //for (int i = 0; i < sdata.Count; i++) //{ // BounceCount = BounceCount + sdata[i].Bounces; // DeleveryAttempts = DeleveryAttempts + sdata[i].DeliveryAttempts; //} //sentCount = DeleveryAttempts - BounceCount; }
public bool SendEmail() { //INITIALIZE AWS CLIENT// AmazonSimpleEmailServiceConfig amConfig = new AmazonSimpleEmailServiceConfig(); //amConfig.UseSecureStringForAwsSecretKey = false; AmazonSimpleEmailServiceClient amzClient = new AmazonSimpleEmailServiceClient( AppSettingHelper.GetAmazonAccessKey(),AppSettingHelper.GetAmazonSecretKey(),//ConfigurationManager.AppSettings["AWSAccessKey"].ToString(), RegionEndpoint.USEast1);// ConfigurationManager.AppSettings["AWSSecretKey"].ToString(), amConfig); //ArrayList that holds To Emails. It can hold 1 Email to any //number of emails in case what to send same message to many users. var to = new List<string>(); to.Add("*****@*****.**"); //Create Your Bcc Addresses as well as Message Body and Subject Destination dest = new Destination(); dest.BccAddresses.Add("*****@*****.**"); //string body = Body; string subject = "Subject : " + "Demo Mail"; Body bdy = new Body(); bdy.Html = new Amazon.SimpleEmail.Model.Content("Test Mail"); Amazon.SimpleEmail.Model.Content title = new Amazon.SimpleEmail.Model.Content(subject); Message message = new Message(title, bdy); //Create A Request to send Email to this ArrayList with this body and subject try { SendEmailRequest ser = new SendEmailRequest("*****@*****.**", dest, message); SendEmailResponse seResponse = amzClient.SendEmail(ser); // SendEmailResult seResult = seResponse.SendEmailResult; } catch (Exception ex) { } return true; }
public static void SendEmailsOnRewardsRedeem( string emailContentPath, string emailPathProductOrderConfirmation, string emailPathOrderConfirmation, string email, string firstname, string lastname, string url, string voucherUrlBase, CheckoutSubmitModel addToMyWallet) { foreach (var purchase in addToMyWallet.Purchases) { if (purchase.NotifyOnRedeem) { var recipientEmail = SetRecipientEmail(purchase.PartnerOwnerEmail); string subjectRewardRedeemed = "GreenMoney Reward Redeemed"; if (string.IsNullOrWhiteSpace(recipientEmail)) { recipientEmail = ConfigurationManager.AppSettings["MasterAdminEmail"]; subjectRewardRedeemed = subjectRewardRedeemed + " - no owner email"; } var redeem_bodyContent = Razor.Parse( System.IO.File.ReadAllText(emailContentPath), new { Email = email, FirstName = firstname, LastName = lastname, PartnerName = purchase.PartnerName, Name = purchase.Name, Category = purchase.Category, Site = url, VoucherUrl = voucherUrlBase } ); // create email request var redeem_request = new SendEmailRequest() .WithDestination(new Destination(new List<string> {recipientEmail})) .WithSource("*****@*****.**") .WithReturnPath("*****@*****.**") .WithMessage(new Message() .WithSubject(new Content(subjectRewardRedeemed)) .WithBody(new Body().WithHtml(new Content(redeem_bodyContent))) ); try { var redeem_client = new AmazonSimpleEmailServiceClient("AKIAIDP5FFSCJUHHC4QA", "NKAzwbtwwhvKuQZj2t6OXxOhaOEuaBYh3E34Jxbs"); redeem_client.SendEmail(redeem_request); } catch (Exception e) { } } } decimal dollartotal = addToMyWallet.Purchases.Sum(i => i.DollarCost); long total = addToMyWallet.Purchases.Sum(i => i.Cost); string emailFile; if (dollartotal > 0) emailFile = emailPathProductOrderConfirmation; else emailFile = emailPathOrderConfirmation; // email content var bodyContent = Razor.Parse( System.IO.File.ReadAllText(emailFile), new { FirstName = firstname, Time = DateTime.Now, Total = total, Items = addToMyWallet.Purchases, HasVouchers = addToMyWallet.Purchases.Any(i => i.DollarCost == 0), VoucherUrl = voucherUrlBase } ); var recipientEmail1 = SetRecipientEmail(email); // create email request var request = new SendEmailRequest() .WithDestination(new Destination(new List<string> { recipientEmail1 })) .WithSource("*****@*****.**") .WithReturnPath("*****@*****.**") .WithMessage(new Message() .WithSubject(new Content("GreenMoney Order Confirmation")) .WithBody(new Body().WithHtml(new Content(bodyContent))) ); try { var client = new AmazonSimpleEmailServiceClient("AKIAIDP5FFSCJUHHC4QA", "NKAzwbtwwhvKuQZj2t6OXxOhaOEuaBYh3E34Jxbs"); client.SendEmail(request); } catch (Exception e) { } }
//Send notification to user via email. /// <summary> /// Uses SES to send an email to a user. /// </summary> /// <param name="email">The email.</param> private void SendEmail(String email) { try { String[] arrayTO = new String[1]; arrayTO[0] = email; List<string> listTO = arrayTO.ToList<String>(); // Construct an object to contain the recipient address. Destination destination = new Destination().WithToAddresses(listTO); String FROM = "*****@*****.**"; String SUBJECT = "Welcome to Cookbook!"; String BODY = "Welcome to Cookbook! Thank you so much for joining us. We hope that you will enjoy using our website."; // Create the subject and body of the message. Content subject = new Content().WithData(SUBJECT); Content textBody = new Content().WithData(BODY); Body body = new Body().WithText(textBody); // Create a message with the specified subject and body. Message message = new Message().WithSubject(subject).WithBody(body); // Assemble the email. SendEmailRequest request = new SendEmailRequest().WithSource(FROM).WithDestination(destination).WithMessage(message); AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(); SendEmailResponse response = client.SendEmail(request); Console.WriteLine("Sent successfully."); } catch (Exception e) { Console.WriteLine(e.Message); } }
public static void SendEmailVerifyAccount(string emailContentPath, string email, string firstname, string url) { // email content var bodyContent = Razor.Parse( System.IO.File.ReadAllText(emailContentPath), new { FirstName = firstname, VerifyUrl = url } ); var recipientEmail = SetRecipientEmail(email); // create email request var request = new SendEmailRequest() .WithDestination(new Destination(new List<string> { recipientEmail })) .WithSource("*****@*****.**") .WithReturnPath("*****@*****.**") .WithMessage(new Message() .WithSubject(new Content("GreenMoney. Please confirm your registration")) .WithBody(new Body().WithHtml(new Content(bodyContent))) ); // send it var client = new AmazonSimpleEmailServiceClient("AKIAIDP5FFSCJUHHC4QA", "NKAzwbtwwhvKuQZj2t6OXxOhaOEuaBYh3E34Jxbs"); client.SendEmail(request); }
public static void SendEmail(string fromEmailAddress, string fromFriendlyName, string toEmailAddress, string emailSubject, string emailBody) { /* var client = new AmazonSimpleEmailServiceClient(Settings.Default.AWSAccessKey, Settings.Default.AWSSecretKey, Amazon.RegionEndpoint.EUWest1); var client = new AmazonSimpleEmailServiceClient("AKIAIJINFUWK57TVYABQ", "AosdbK3YfN8zvFltHNDuxFZrHVZNlLeBZQ1pGKG8dFCd", Amazon.RegionEndpoint.EUWest1); */ /* var destination = new Destination(new List<string>() {toEmailAddress}); var subjectContent = new Content(subject); var bodyContent = new Content(body); var messageBody = new Body(bodyContent); var message = new Message(subjectContent, messageBody); var request = new SendEmailRequest(fromEmailAddress, destination, message); client.SendEmail(request); */ String FROM = fromEmailAddress; // Replace with your "From" address. This address must be verified. String TO = toEmailAddress; // Replace with a "To" address. If you have not yet requested // production access, this address must be verified. const String SUBJECT = "Amazon SES test (AWS SDK for .NET)"; const String BODY = "This email was sent through Amazon SES by using the AWS SDK for .NET."; // Construct an object to contain the recipient address. Destination destination = new Destination(); destination.ToAddresses = (new List<string>() { TO }); // Create the subject and body of the message. Content subject = new Content(SUBJECT); Content textBody = new Content(BODY); Body body = new Body(textBody); // Create a message with the specified subject and body. Message message = new Message(subject, body); // Assemble the email. SendEmailRequest request = new SendEmailRequest(FROM, destination, message); // Choose the AWS region of the Amazon SES endpoint you want to connect to. Note that your production // access status, sending limits, and Amazon SES identity-related settings are specific to a given // AWS region, so be sure to select an AWS region in which you set up Amazon SES. Here, we are using // the US East (N. Virginia) region. Examples of other regions that Amazon SES supports are USWest2 // and EUWest1. For a complete list, see http://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html Amazon.RegionEndpoint REGION = Amazon.RegionEndpoint.EUWest1; // Instantiate an Amazon SES client, which will make the service call. var client = new AmazonSimpleEmailServiceClient(Settings.Default.AWSAccessKey, Settings.Default.AWSSecretKey, Amazon.RegionEndpoint.EUWest1); // Send the email. // client.VerifyEmailAddress(new VerifyEmailAddressRequest() {EmailAddress = fromEmailAddress}); client.SendEmail(request); Console.WriteLine("Email sent!"); }
public static void SendEmailResetPassword(string emailContentPath, UserModel user, string password, string url, MembershipUser membershipUser) { // email content var bodyContent = Razor.Parse( System.IO.File.ReadAllText(emailContentPath), new { FirstName = user.FirstName, Password = password, LoginUrl = url } ); var recipientEmail = SetRecipientEmail(membershipUser.Email); try { // create email request var request = new SendEmailRequest() .WithDestination(new Destination(new List<string> {recipientEmail})) .WithSource("*****@*****.**") .WithReturnPath("*****@*****.**") .WithMessage(new Message() .WithSubject(new Content("GreenMoney Password Reset")) .WithBody(new Body().WithHtml(new Content(bodyContent))) ); // send it var client = new AmazonSimpleEmailServiceClient("AKIAIDP5FFSCJUHHC4QA", "NKAzwbtwwhvKuQZj2t6OXxOhaOEuaBYh3E34Jxbs"); client.SendEmail(request); } catch (Exception) { } }
public bool sendEmail(Model.Email email) { bool ret = false; SendEmailRequest msg = new SendEmailRequest(); msg.Destination = new Destination(); msg.Destination.ToAddresses = email.to; if (email.cc != null && email.cc.Count > 0) { msg.Destination.CcAddresses = email.cc; } if (email.bcc != null && email.bcc.Count > 0) { msg.Destination.BccAddresses = email.bcc; } if (email.replyToAddresses != null && email.replyToAddresses.Count > 0) { msg.ReplyToAddresses = email.replyToAddresses; } if (email.returnPath != String.Empty) { msg.ReturnPath = email.returnPath; } msg.Source = email.source; msg.Message = new Message(); msg.Message.Subject = new Amazon.SimpleEmail.Model.Content(); ////string c = email.Message.Subject.Charset; msg.Message.Subject.Data = email.subject; msg.Message.Body = new Body(); // if (email.text != String.Empty) // { msg.Message.Body.Text = new Amazon.SimpleEmail.Model.Content(); msg.Message.Body.Text.Data = email.text; //} //if (email.html != String.Empty) // { msg.Message.Body.Html = new Amazon.SimpleEmail.Model.Content(); msg.Message.Body.Html.Data = email.html; //} using (AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(_accessKeyID, _secretAccessKeyID)) { SendEmailResponse response = client.SendEmail(msg); ret = true; } return ret; }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // 尝试注册用户 MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); if (createStatus == MembershipCreateStatus.Success) { //Send email by amazon ses string accessKey = "AKIAIO4BEQ2UGFAMHRFQ"; string secretAccessKey = "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"; AmazonSimpleEmailServiceConfig amazonConfiguration = new AmazonSimpleEmailServiceConfig(); AmazonSimpleEmailServiceClient clientMail = new AmazonSimpleEmailServiceClient(accessKey, secretAccessKey, amazonConfiguration); Destination destination = new Destination(); destination.ToAddresses.Add(model.Email); Body body = new Body() { Html = new Content("Welcome to AIRPDF "+"Your account is: "+model.UserName+" Your password is: "+model.ConfirmPassword) }; Content subject = new Content("Welcome to AIRPDF!"); Message message = new Message(subject, body); SendEmailRequest sendEmailRequest = new SendEmailRequest("*****@*****.**", destination, message); clientMail.SendEmail(sendEmailRequest); FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */); return RedirectToAction("Index", "pdf"); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return View(model); }
//Send notification to user via email. /// <summary> /// Uses SES to send an email to a user. /// </summary> /// <param name="userID">The user being sent the email</param> /// <param name="inputSubject">The subject of the email</param> /// <param name="inputBody">The body of the email</param> public static void SendEmail(int userID, string inputSubject, string inputBody) { try { String email = (from userprofiles in userDb.UserProfiles where userprofiles.UserId == userID select userprofiles.Email).FirstOrDefault(); ; //Find userID's email address. if (inputSubject == "") { inputSubject = "The Cookbook - New Notification Waiting For You"; } if (inputBody == "") { inputBody = "You have received a new notification. Visit The Cookbook for more information."; } String[] arrayTO = new String[1]; arrayTO[0] = email; List<string> listTO = arrayTO.ToList<String>(); // Construct an object to contain the recipient address. Destination destination = new Destination().WithToAddresses(listTO); String FROM = "*****@*****.**"; String SUBJECT = inputSubject; String BODY = inputBody; // Create the subject and body of the message. Content subject = new Content().WithData(SUBJECT); Content textBody = new Content().WithData(BODY); Body body = new Body().WithText(textBody); // Create a message with the specified subject and body. Message message = new Message().WithSubject(subject).WithBody(body); // Assemble the email. SendEmailRequest request = new SendEmailRequest().WithSource(FROM).WithDestination(destination).WithMessage(message); AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(); SendEmailResponse response = client.SendEmail(request); Console.WriteLine("Sent successfully."); } catch (Exception e) { Console.WriteLine(e.Message); } }