public void Notify(ScheduledEvent ev) { string text = String.Join(Environment.NewLine, "It's time for " + ev.Name); if (ev.Description != "") { text = String.Join(Environment.NewLine, text, "Description:", ev.Description); } if (ev.Place != "") { text = String.Join(Environment.NewLine, text, "Place:", ev.Place); } var msg = new AE.Net.Mail.MailMessage { Subject = "Notification", Body = text, From = new MailAddress(mail) }; msg.To.Add(new MailAddress(mail)); msg.ReplyTo.Add(msg.From); var msgStr = new StringWriter(); msg.Save(msgStr); var gmail = service; var result = gmail.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); }
public void ApiTest() { //UsersResource.LabelsResource.ListRequest request = service.Users.Labels.List("me"); // List labels. //IList<Label> labels = request.Execute().Labels; //var msg = new Message(); ///////// var msg = new AE.Net.Mail.MailMessage { Subject = "Meta", Body = @"CANTSTOP!@#$%^&*()_+-=/\""WONTSTOP", From = new MailAddress($"{DbName}@gmail.com") }; msg.To.Add(new MailAddress($"{DbName}@gmail.com")); msg.ReplyTo.Add(msg.From); // Bounces without this!! var gmailMsg = ConvertToGmailMessage(msg); ////////////// var draft = new Draft { Message = gmailMsg }; //service.Users.Drafts.Create(draft, "me").Execute(); //Next stop.... how to add an attachment. }
private void ContructRawAttacments(AE.Net.Mail.MailMessage msg) { foreach (var child in StackPanelAttachments.Children) { if (child is TextBlock txtBlock) { var fullPath = txtBlock.DataContext as string; var fileName = txtBlock.Text; if (fileName.IsNotEmpty() && fullPath.IsNotEmpty()) { try { var bytes = File.ReadAllBytes(fullPath); var attachment = new AE.Net.Mail.Attachment( bytes, System.Web.MimeMapping.GetMimeMapping(fileName), fileName, true); msg.Attachments.Add(attachment); } catch (Exception e) { Debug.WriteLine(e.Message); } } } } }
public void SendIt(string From, string To, string Subject, string Body) { System.Diagnostics.Debug.WriteLine("TRYING TO SEND IT. FROM IS --" + From + "-- AND TO IS --" + To + "--"); var msg = new AE.Net.Mail.MailMessage { Subject = Subject, Body = Body, From = new MailAddress(From) }; msg.To.Add(new MailAddress(To)); msg.ReplyTo.Add(msg.From); var msgStr = new StringWriter(); msg.Save(msgStr); var gmail = new GmailService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); var result = gmail.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); Console.WriteLine("Message ID {0} sent.", result.Id); }
public static void Send(AE.Net.Mail.MailMessage message, bool?isHighPriority = null) { if (isHighPriority == null) { isHighPriority = false; } var email = new MailMessage { Sender = new MailAddress(message.From.Address, message.From.DisplayName), From = new MailAddress(message.From.Address, message.From.DisplayName), Subject = message.Subject, Body = message.Body, IsBodyHtml = true, Priority = isHighPriority.Value ? MailPriority.High : MailPriority.Normal }; foreach (var add in message.To) { email.To.Add(new MailAddress(add.Address, add.DisplayName)); } try { new SmtpClient().Send(email); } catch (Exception e) { Log.Error(String.Format("There was an error sending the email {0}.", message.To.First().Address), e); throw; } }
public async Task SendEmail(EmailContent model, CancellationToken cancellationToken) { if (await checkCredential()) { //send email var msg = new AE.Net.Mail.MailMessage { Subject = model.subject, Body = model.body, From = new MailAddress(emailAddress), }; string Mails = model.to; var recipients = Mails.Split(' '); //var recipients = new[] { model.to}; foreach (var recipient in recipients) { msg.To.Add(new MailAddress(recipient)); msg.ReplyTo.Add(msg.From); var msgStr = new StringWriter(); msg.Save(msgStr); await service.Users.Messages.Send(new Message() { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").ExecuteAsync(); } } }
public void DisplayMail(int IndexInArray) { mCurrentMail = Connections.getMessageByIndex(IndexInArray); AddressLabel.Text = mCurrentMail.Sender + "(" + mCurrentMail.From + ")\n" + mCurrentMail.Subject; MailBody.Text = mCurrentMail.Body; WebBrowser.DocumentText = mCurrentMail.Body; }
public static void SendIt(string message, string emailSender) { var msg = new AE.Net.Mail.MailMessage { Subject = "BinanceAPI Message", Body = message, From = new MailAddress(emailSender) }; msg.To.Add(new MailAddress("*****@*****.**")); msg.To.Add(new MailAddress("*****@*****.**")); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); var gmail = GService(); var result = gmail.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); Console.WriteLine("Message ID {0} sent.", result.Id); }
public static void SendIt(EMail email) { var msg = new AE.Net.Mail.MailMessage { Subject = email.Subject, Body = email.Body, From = new MailAddress(UserName) }; msg.To.Add(new MailAddress(email.ToEmailAddress)); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); // Context is a separate bit of code that provides OAuth context; // your construction of GmailService will be different from mine. if (_service == null) { _service = new GMailService(); } _service.Service.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, UserName).Execute(); }
private static void SendIt(BaseClientService.Initializer initializer) { var msg = new AE.Net.Mail.MailMessage { ContentType = "text/html", Subject = "Your Subject", Body = @"<html> <body> Hello <strong>World!</strong> </body> </html>", From = new MailAddress("*****@*****.**") }; msg.To.Add(new MailAddress("*****@*****.**")); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); var gmail = new GmailService(initializer); var result = gmail.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); Console.WriteLine("Message ID {0} sent.", result.Id); }
public async Task SendMailAsync(string accessToken, string subject, string to, string body, string from) { var service = new GmailService(new BaseClientService.Initializer { HttpClientInitializer = GoogleCredential.FromAccessToken(accessToken), }); //send email var msg = new AE.Net.Mail.MailMessage { Subject = subject, Body = body, From = new MailAddress(from), }; string Mails = to; var recipients = Mails.Split(' '); foreach (var recipient in recipients) { msg.To.Add(new MailAddress(recipient)); msg.ReplyTo.Add(msg.From); var msgStr = new StringWriter(); msg.Save(msgStr); await service.Users.Messages.Send(new Message() { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").ExecuteAsync(); } }
/// <summary> /// Tries 5 times to sends a mail indicating the status of the program to the specified address. Returns whether it was successful /// <para>This method does NOT print information to the console.</para> /// </summary> /// <param name="address">The mail address to send status data to</param> /// <returns>Whether the mail was sent successfully</returns> public static bool SendStatusTo(String address) { for (int i = 0; i < 5; i++) { try { StringBuilder builder = new StringBuilder(512); IAction[] actions = Program.queue.ToArray(); builder.Append("A PaintDrawer Status Request was recieved from this address.\r\nQueue<IAction>().ToArray() returned: {"); for (int a = 0; a < actions.Length; a++) { builder.Append(" "); builder.Append(actions[a].ToString()); builder.Append("\r\n"); } builder.Append("}\r\nThat is a total of "); builder.Append(actions.Length); builder.Append(" IAction-s.\r\n\r\n"); builder.Append("Program.Time = "); builder.Append(Program.Time); builder.Append("\r\nProgram.LastDraw = "); builder.Append(Program.LastDraw); builder.Append("\r\nAccount.LastMailRecieved = "); builder.Append(Account.LastMailRecieved); builder.Append("\r\nAccount.LastRead = "); builder.Append(Account.LastRead); builder.Append("\r\nAccount.LastSuccessfullRead = "); builder.Append(Account.LastSuccessfullRead); var msg = new AE.Net.Mail.MailMessage { Subject = "PaintDrawer Status Request", Body = builder.ToString(), From = new MailAddress(MyMailAddress) }; msg.To.Add(new MailAddress(address)); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); GmailService gmail = Account.service; Message result = gmail.Users.Messages.Send(new Message { Raw = _base64UrlEncode(msgStr.ToString()) }, "me").Execute(); return(true); } catch //(Exception e) { } } return(false); }
public Message(AE.Net.Mail.MailMessage mailMessage) { DestinationEmail = mailMessage.To.FirstOrDefault().Address; SenderEmail = mailMessage.From.Address; Subject = mailMessage.Subject; Text = mailMessage.Body; ReceiveTime = mailMessage.Date; SendTime = null; }
private static Message ConvertToGmailMessage(AE.Net.Mail.MailMessage message) { var msgStr = new StringWriter(); message.Save(msgStr); return(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }); }
public static void TestMailSend() { MailMessage mail = new MailMessage(); AE.Net.Mail.MailMessage mailMessage = new AE.Net.Mail.MailMessage(); mail.Attachments.Add(new Attachment("C:\\Users\\JOEY\\Desktop\\notes about design patterns\\Notes.txt")); Console.WriteLine(mail.ToString()); }
public bool AENetMailParser() { foreach (var stream in _streams) { var message = new AE.Net.Mail.MailMessage(); message.Load(stream, false, (int)stream.Length); stream.Position = 0; } return(true); }
public async Task <ActionResult> Compose(EmailViewModel model) { var result = await new AuthorizationCodeMvcApp(this, new AppFlowMetadata(_authTokenService)). AuthorizeAsync(CancellationToken.None); if (result.Credential == null) { return(new RedirectResult(result.RedirectUri)); } else { var service = new GmailService(new BaseClientService.Initializer { HttpClientInitializer = result.Credential, ApplicationName = "Gmail webapp" }); var msg = new AE.Net.Mail.MailMessage { ContentType = "text/plain", Subject = model.Subject, Body = model.Body, From = new MailAddress(model.From) }; var toAddresses = model.To.Split(','); foreach (var to in toAddresses) { msg.To.Add(new MailAddress(to)); } var ccAddresses = model.Cc.Split(','); foreach (var cc in ccAddresses) { msg.Cc.Add(new MailAddress(cc)); } var BccAddresses = model.Bcc.Split(','); foreach (var bcc in BccAddresses) { msg.Bcc.Add(new MailAddress(bcc)); } msg.ReplyTo.Add(msg.From); var msgStr = new StringWriter(); msg.Save(msgStr); service.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); return(RedirectToAction("Inbox")); } }
public BaseReturn <bool> sendMailReply(Email mail, string replymessage) { BaseReturn <bool> baseObject = new BaseReturn <bool>(); try { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var enc1252 = Encoding.GetEncoding(1252); mail.To = mail.From; mail.From = Config.serviceMailId; mail.Body = replymessage; var msg = new AE.Net.Mail.MailMessage { Subject = "RE : " + mail.Subject, Body = mail.Body, ContentType = "text/html", From = new MailAddress(mail.From) }; msg.To.Add(new MailAddress(mail.To)); msg.ReplyTo.Add(new MailAddress(mail.From)); mail.CC.Split(',').ToList().ForEach(addr => { if (addr.Trim() != "") { msg.Cc.Add(new MailAddress(addr)); } }); var msgStr = new StringWriter(); msg.Save(msgStr); var result = _service.Users.Messages.Send(new Message { ThreadId = mail.MailId, Id = mail.MailId, Raw = CommonFunctions.Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); saveReplyMailInfo(mail); baseObject.Success = true; baseObject.Data = true; } catch (Exception ex) { baseObject.Success = false; baseObject.Message = "Error Occured."; } return(baseObject); }
public void SendMail(string To, string Subject, string Body) { UserCredential credential; var PathToClientSecret = System.Web.HttpContext.Current.Request.MapPath("~\\Content\\client_secret.json"); //using (var stream = // new FileStream("client_secret.json", FileMode.Open, FileAccess.Read)) //{ using (var stream = new FileStream(PathToClientSecret, FileMode.Open, FileAccess.Read)) { string credPath = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Personal); credPath = Path.Combine(credPath, ".credentials/client_secret.json"); credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; Console.WriteLine("Credential file saved to: " + credPath); } // Create Gmail API service. var service = new GmailService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); var msg = new AE.Net.Mail.MailMessage { Subject = "=?UTF-8?B?" + Base64UrlEncode(Subject) + "?=", Body = Body, From = new MailAddress("*****@*****.**"), ContentType = "text/html" }; msg.To.Add(new MailAddress(To)); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); UsersResource.MessagesResource.SendRequest request = service.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me"); var resultado = request.Execute(); }
public static void SendIt() { UserCredential credential; using (var stream = new FileStream("credentials_gmail.json", FileMode.Open, FileAccess.Read)) { // The file token.json stores the user's access and refresh tokens, and is created // automatically when the authorization flow completes for the first time. string credPath = "token.json"; credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; Console.WriteLine("Credential file saved to: " + credPath); } var msg = new AE.Net.Mail.MailMessage { Subject = "Your Subject", Body = getBody(), From = new MailAddress("*****@*****.**") }; msg.To.Add(new MailAddress("*****@*****.**")); msg.To.Add(new MailAddress("*****@*****.**")); msg.To.Add(new MailAddress("*****@*****.**")); msg.To.Add(new MailAddress("*****@*****.**")); msg.To.Add(new MailAddress("*****@*****.**")); msg.To.Add(new MailAddress("*****@*****.**")); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); var gmail = new GmailService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); var result = gmail.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); List <MailAddress> list = msg.To.ToList <MailAddress>(); Console.WriteLine("Message ID {0} sent. All Reciepents {1}", result.Id, msg.To.AsEnumerable <MailAddress>().ToString()); foreach (MailAddress ma in msg.To.ToList <MailAddress>()) { Console.WriteLine("Receiver : " + ma.Address + " ," + ma.DisplayName + " ," + ma.Host + ", " + ma.User + " ," + ma.ToString()); } Console.Read(); }
public void AENetMail() { using (var stream = new MemoryStream(BenchmarkData, false)) { for (int i = 0; i < iterations; i++) { var message = new AE.Net.Mail.MailMessage(); message.Load(stream, false, (int)stream.Length); stream.Position = 0; } } }
/// <summary> /// Tries 5 times to send a mail indicating the valid characters. Returns whether it was successful /// <para>This method does NOT print information to the console.</para> /// </summary> /// <param name="address">The mail address to send valid char data to</param> /// <returns>Whether the mail was sent successfully</returns> public static bool SendValidCharsTo(String address) { for (int i = 0; i < 5; i++) { try { StringBuilder builder = new StringBuilder(512); builder.Append("Valid Characters: \r\n"); for (int ci = 0; ci < PaintDrawer.Letters.CharFont.MaxCharNumericValue; ci++) { char c = (char)ci; if (Program.font.DoesCharExist(c)) { builder.Append("\r\nChar "); builder.Append(ci); builder.Append("; '"); builder.Append(c); builder.Append("'."); } } builder.Append("Keep in mind these are encoded in UTF-16, which is the format chosen by the .NET Framework."); var msg = new AE.Net.Mail.MailMessage { Subject = "PaintDrawer Valid Characters Request", Body = builder.ToString(), From = new MailAddress(MyMailAddress) }; msg.To.Add(new MailAddress(address)); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); GmailService gmail = Account.service; Message result = gmail.Users.Messages.Send(new Message { Raw = _base64UrlEncode(msgStr.ToString()) }, "me").Execute(); return(true); } catch { } } return(false); }
static TimeSpan MeasureAENetMail(Stream stream, int count) { var stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < count; i++) { var message = new AE.Net.Mail.MailMessage(); message.Load(stream, false, (int)stream.Length); stream.Position = 0; } stopwatch.Stop(); return(stopwatch.Elapsed); }
public bool SendMail(string sendTo, string messageSubject, string messageBody) { bool retVal = false; try { var msg = new AE.Net.Mail.MailMessage { Subject = messageSubject, Body = messageBody, From = new MailAddress(sendingUserEmail) }; msg.To.Add(new MailAddress(sendTo)); msg.ReplyTo.Add(msg.From); var msgStr = new StringWriter(); msg.Save(msgStr); UserCredential credential; string path = HttpContext.Current.Server.MapPath("\\"); using (var stream = new FileStream($"{path}credentials.json", FileMode.Open, FileAccess.Read)) { string credPath = $"{path}token.json"; credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, sendingUserEmail, CancellationToken.None, new FileDataStore(credPath, true)).Result; } // Create Gmail API service. var gmailService = new GmailService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); var result = gmailService.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); Console.WriteLine("Message ID {0} sent.", result.Id); } catch (Exception ex) { ErrorDescription = ex.Message; } return(retVal); }
public void SendEmail(User user, string subject, string text) { var msg = new AE.Net.Mail.MailMessage { Subject = subject, Body = text, From = new MailAddress(config.NotificationAccount) }; msg.To.Add(new MailAddress(user.Email)); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); var m = new Message { Raw = Base64UrlEncode(msgStr.ToString()) }; gmailService.Value.Users.Messages.Send(m, "me").Execute(); }
public int TakeFood(FoodModel food, string email) { Food foodTaken = db.Foods.SingleOrDefault(x => x.Guid == food.GuidLine); foodTaken.TakenBy = db.Users.SingleOrDefault(x => x.Email == email).ID; try { db.SubmitChanges(); var msg = new AE.Net.Mail.MailMessage { Subject = "Someone just took your food!", Body = $"Someone just got interested in your offer and took the food. You can contact him/her via this email address: {email}", From = new MailAddress("*****@*****.**") }; msg.To.Add(new MailAddress(foodTaken.User.Email)); msg.ReplyTo.Add(msg.From); var msgStr = new StringWriter(); msg.Save(msgStr); UserCredential credential; using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) { // The file token.json stores the user's access and refresh tokens, and is created // automatically when the authorization flow completes for the first time. string credPath = "token.json"; credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; Console.WriteLine("Credential file saved to: " + credPath); } var gmail = new GmailService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName }); var result = gmail.Users.Messages.Send(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); } catch (Exception e) { return(0); } return(1); }
//Defines content of email as well as sends out the email. Autentication with Gmail. public static void SendIt() {//Defines Email content var msg = new AE.Net.Mail.MailMessage { Subject = "Onekama Voucher Program", Body = "A voucher with serial number " + VoucherForm.serial + " for $" + VoucherForm.amount + " has been created.", From = new MailAddress("*****@*****.**") }; msg.To.Add(new MailAddress("*****@*****.**")); msg.ReplyTo.Add(msg.From); // Fills in required field, from. var msgStr = new StringWriter(); msg.Save(msgStr); //Gmail Authentication UserCredential credential; using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) { // The file token.json stores the user's access and refresh tokens, and is created // automatically when the authorization flow completes for the first time. string credPath = "token.json"; credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "admin", CancellationToken.None, new FileDataStore(credPath, true)).Result; Console.WriteLine("Credential file saved to: " + credPath); } var gmail = new GmailService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); var result = gmail.Users.Messages.Send(new Google.Apis.Gmail.v1.Data.Message { Raw = Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); MessageBox.Show("Voucher was Created.", "Success! You're A Winner! Don't you ever forget that."); }
private string ConstructRawMessage() { var msg = new AE.Net.Mail.MailMessage { Subject = TextBoxSubject.Text, Body = MsgTextBox.Text, From = new MailAddress(Credentials.Email) }; msg.To.Add(new MailAddress(TextBoxTo.Text)); msg.ReplyTo.Add(msg.From); // Bounces without this!! ContructRawAttacments(msg); var msgStr = new StringWriter(); msg.Save(msgStr); return(AppCode.Encoding.Base64UrlEncode(msgStr.ToString())); }
public bool SendInfoToClient(Purchase purchase) { var shopEmail = ConfigurationManager.AppSettings[UsernameKey]; var messageToClient = new MailMessage { Subject = "Guitar Shop", Body = $"Dear {purchase.Name}. Your purchase id is {purchase.PurchaseId} - {purchase.GuitarName}.\n" + "Wait for our call for a sec.", From = new MailAddress(shopEmail) }; messageToClient.To.Add(new MailAddress(purchase.Email)); var messageToShop = new MailMessage { Subject = "Client bought a new stuff", Body = $"Client {purchase.Name} with id - {purchase.PurchaseId} bought a {purchase.GuitarName}", From = new MailAddress(shopEmail) }; messageToShop.To.Add(new MailAddress(shopEmail)); using (var smtpServer = new SmtpClient("smtp.gmail.com") { Port = 587, EnableSsl = true, Credentials = new NetworkCredential(shopEmail, ConfigurationManager.AppSettings[PasswordKey]), Timeout = 5000 }) { try { smtpServer.Send(messageToClient); smtpServer.Send(messageToShop); } catch (SmtpException) { smtpServer.Dispose(); return false; } } return true; }
public void DoFormatMail(Mail mail) { StringBuilder stringBuilder = new StringBuilder(); AE.Net.Mail.MailMessage mailMessage = new AE.Net.Mail.MailMessage(); AE.Net.Mail.Attachment asdf = new AE.Net.Mail.Attachment(); //MailTemplate pull CompositeIterator iterator = (CompositeIterator)mail.CreateIterator(); MailTemplate mailTemplate = (MailTemplate)iterator.First(); //AttachmentBox pull iterator = (CompositeIterator)mailTemplate.CreateIterator(); Attachments attachmentBox = (Attachments)iterator.First(); //Attachments pull iterator = (CompositeIterator)attachmentBox.CreateIterator(); while (!iterator.IsDone()) { models.components.Attachment attachment = (models.components.Attachment)iterator.CurrentItem(); mailMessage.Attachments.Add(new AE.Net.Mail.Attachment { Body = attachment.GetFileDirectory() }); } mailMessage.To.Add(new MailAddress(mail.TargetMail)); mailMessage.Subject = mailTemplate.Subject; mailMessage.Body = mailTemplate.Body; var msgStr = new StringWriter(); mailMessage.Save(msgStr); mail.FormatedMail = msgStr.ToString(); }
private Message CreateMessage(string to, string subject = "", string body = "") { var newEmail = new AE.Net.Mail.MailMessage { Subject = subject, Body = body, From = new MailAddress("*****@*****.**", "Keyser Soze") }; newEmail.To.Add(new MailAddress(to)); newEmail.ReplyTo.Add(newEmail.From); var emailString = new StringWriter(); newEmail.Save(emailString); Message email = new Message { Raw = Encoder.ConvertToBase64(emailString.ToString()) }; return(email); }
public Message createMessage(string subject , string body , string fromMail , string toMail) { var msg = new AE.Net.Mail.MailMessage { Subject = subject, Body = body, From = new MailAddress(fromMail) }; msg.To.Add(new MailAddress(toMail)); msg.ReplyTo.Add(msg.From); // Bounces without this!! var msgStr = new StringWriter(); msg.Save(msgStr); return(new Message { Raw = Base64UrlEncode(msgStr.ToString()) }); }