protected virtual void FillRecepientActivityField(Activity activity, Guid recordId, string schemaName) { var contactEsq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, schemaName); string contactIdName = contactEsq.AddColumn("Contact.Id").Name; string emailColumnName = contactEsq.AddColumn("Contact.Email").Name; string emailTitleColumnName = contactEsq.AddColumn("ParentActivity.Title").Name; string emailSenderColumnName = contactEsq.AddColumn("ParentActivity.Sender").Name; string emailRecipientColumnName = contactEsq.AddColumn("ParentActivity.Recepient").Name; string emailCcColumnName = contactEsq.AddColumn("ParentActivity.CopyRecepient").Name; string emailBlindCopyColumnName = contactEsq.AddColumn("ParentActivity.BlindCopyRecepient").Name; var contact = contactEsq.GetEntity(UserConnection, recordId); if (contact != null) { Guid contactId = contact.GetTypedColumnValue <Guid>(contactIdName); activity.SetColumnValue("ContactId", contactId); string contactEmail = contact.GetTypedColumnValue <string>(emailSenderColumnName); if (contactEmail.IsNullOrEmpty()) { contactEmail = contact.GetTypedColumnValue <string>(emailColumnName).IsNullOrEmpty() ? ContactUtilities.GetLastAddContactEmail(UserConnection, contact.GetTypedColumnValue <Guid>(contactIdName)) : contact.GetTypedColumnValue <string>(emailColumnName); } activity.SetColumnValue("Recepient", contactEmail); string title = contact.GetTypedColumnValue <string>(emailTitleColumnName); activity.SetColumnValue("Title", title); string recipient = contact.GetTypedColumnValue <string>(emailRecipientColumnName); string copyRecipient = contact.GetTypedColumnValue <string>(emailCcColumnName); string blindCopyRecipient = contact.GetTypedColumnValue <string>(emailBlindCopyColumnName); activity.SetColumnValue("CopyRecepient", copyRecipient); string recipients = recipient + ";" + copyRecipient + ";" + blindCopyRecipient; EmailSender = EmailSenderObtainerWrapper.GetSupportMailBox(recipients, contactId); } }
/// <summary> /// Initializes a new instance of the <see cref="EmailWithMacrosManager"/> class. /// </summary> /// <param name="userConnection">The user connection.</param> public EmailWithMacrosManager(UserConnection userConnection) : base(userConnection) { InitializeReplacementMap(); IncindentRegistrationMailboxFilter = new IncindentRegistrationMailboxFilter(userConnection); EmailSenderObtainerWrapper = new EmailSenderObtainerWrapper(userConnection); AsyncEmailSender = new AsyncEmailSender(userConnection); }
public SenderObtainingServiceResponse ObtainSenderMailbox(string recipients, Guid contactId, Guid categoryId) { var wrapper = new EmailSenderObtainerWrapper(UserConnection); var mailbox = new MailboxSyncSettings(UserConnection); try { var mailboxName = wrapper.GetSupportMailBox(recipients, contactId, categoryId); return(new SenderObtainingServiceResponse { Success = !string.IsNullOrEmpty(mailboxName), MailboxName = mailboxName, }); } catch (Exception e) { return(new SenderObtainingServiceResponse { Success = false, Exception = e }); } }
/// <summary> /// Gets e-mail sender by given case data. /// It uses <see cref="EmailSenderObtainerWrapper"/>. /// </summary> /// <param name="data">Case data.</param> /// <returns>E-mail sender.</returns> protected string GetSender(CaseData data) { return(EmailSenderObtainerWrapper.GetSupportMailBox(data.Recipients, data.ContactId, data.CategoryId)); }