public void PreviewMessage(dtoManagerTemplateMail template, String fakeName, String fakeSurname, String fakeTaxCode, String fakeMail, lm.Comol.Core.MailCommons.Domain.Configurations.SmtpServiceConfig smtpConfig, String websiteUrl, Dictionary <SubmissionTranslations, string> translations) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { Language dLanguage = CurrentManager.GetDefaultLanguage(); litePerson currentUser = CurrentManager.GetLitePerson(UserContext.CurrentUserID); litePerson fakeUser = new litePerson(); fakeUser.TypeID = (int)UserTypeStandard.Student; fakeUser.Name = fakeName; fakeUser.Surname = fakeSurname; fakeUser.Mail = fakeMail; fakeUser.TaxCode = fakeTaxCode; fakeUser.LanguageID = currentUser.LanguageID; lm.Comol.Core.Mail.dtoMailMessage message = CallService.GetMailPreview(View.IdCall, template, currentUser, smtpConfig, websiteUrl, translations); String recipients = template.NotifyTo; if (String.IsNullOrEmpty(recipients)) { recipients = currentUser.Mail; } else if (recipients.Contains(",")) { recipients = recipients.Replace(",", ";"); } View.DisplayMessagePreview(new lm.Comol.Core.Mail.dtoMailMessagePreview(currentUser.LanguageID, dLanguage, message, template.MailSettings, smtpConfig), recipients); } }
private void SendMailToProfiles(List <ProfileImportAction> actions, List <dtoImportedProfile> profiles, lm.Comol.Core.Mail.dtoMailContent mailContent, List <ProfileAttributeType> attributes, List <dtoImportedProfile> notSentMail) { Int32 index = 1; Boolean mailSent = false; Int32 actionIndex = actions.Count() - ((actions.Contains(ProfileImportAction.AddToOtherOrganizations) || actions.Contains(ProfileImportAction.AddToCommunities)) ? 1 : 0); Person currentUser = CurrentManager.GetPerson(UserContext.CurrentUserID); lm.Comol.Core.Mail.MailService mailService = new lm.Comol.Core.Mail.MailService(View.CurrentSmtpConfig, mailContent.Settings); Language dLanguage = CurrentManager.GetDefaultLanguage(); foreach (dtoImportedProfile profile in profiles) { if (currentUser != null) { lm.Comol.Core.Mail.dtoMailMessage message = new lm.Comol.Core.Mail.dtoMailMessage(mailContent.Subject, AnalyzeBody(mailContent.Body, profile, attributes)); message.FromUser = new System.Net.Mail.MailAddress(currentUser.Mail, currentUser.SurnameAndName); message.To.Add(new System.Net.Mail.MailAddress(profile.Profile.Mail, profile.Profile.DisplayName)); //'dtoMessage.To.Add() mailSent = (mailService.SendMail(currentUser.LanguageID, dLanguage, message) == Mail.MailException.MailSent); } else { View.UpdateSendMailToProfile(actionIndex, profiles.Count, index, mailSent, profile.Profile.DisplayName); } if (!mailSent) { notSentMail.Add(profile); } index++; } }