public static string ParceAddresses(EmailAddressType[] addresses) { if (addresses == null || addresses.Length <= 0) { return(null); } return(PXDBEmailAttribute.ToString(addresses.Select(_ => new MailAddress(_.EmailAddress, _.Name)))); }
protected void SendCopyMessageToInside(PXGraph graph, EMailAccount account, CRSMEmail message, IEnumerable <MailAddress> addresses) { var cache = graph.Caches[message.GetType()]; var copy = (CRSMEmail)cache.CreateCopy(message); copy.NoteID = null; copy.EmailNoteID = null; copy.IsIncome = false; copy.ParentNoteID = message.NoteID; MailAddress address = null; copy.MailFrom = EmailParser.TryParse(message.MailFrom, out address) ? new MailAddress(account.Address, address.DisplayName).ToString() : account.Address; copy.MailTo = PXDBEmailAttribute.ToString(addresses); //TODO: need add address description copy.MailCc = null; copy.MailBcc = null; copy.MailReply = copy.MailFrom; copy.MPStatus = MailStatusListAttribute.PreProcess; copy.ClassID = CRActivityClass.EmailRouting; new AddInfoEmailProcessor().Process(new EmailProcessEventArgs(graph, account, copy)); copy.RefNoteID = null; copy.BAccountID = null; copy.ContactID = null; copy.Pop3UID = null; copy.ImapUID = null; var imcUid = Guid.NewGuid(); copy.ImcUID = imcUid; copy.MessageId = this.GetType().Name + "_" + imcUid.ToString().Replace("-", string.Empty); copy.OwnerID = null; copy.WorkgroupID = null; copy = (CRSMEmail)cache.CreateCopy(cache.Insert(copy)); //Update owner and reset owner if employee not found copy.OwnerID = message.OwnerID; try { cache.Update(copy); } catch (PXSetPropertyException) { copy.OwnerID = null; copy = (CRSMEmail)cache.CreateCopy(cache.Update(copy)); } copy.IsPrivate = message.IsPrivate; copy.WorkgroupID = message.WorkgroupID; var noteFiles = PXNoteAttribute.GetFileNotes(cache, message); if (noteFiles != null) { PXNoteAttribute.SetFileNotes(cache, copy, noteFiles); } }
protected static string MergeAddressList(CRSMEmail email, string addressList, string sourceList) { if (string.IsNullOrEmpty(addressList)) { return(sourceList); } List <MailAddress> result = new List <MailAddress>(); var index = new HashSet <string>(); foreach (MailAddress address in EmailParser.ParseAddresses(addressList)) { if (index.Contains(address.Address)) { continue; } if (email.MailTo != null && email.MailTo.Contains(address.Address, StringComparison.InvariantCultureIgnoreCase)) { continue; } if (email.MailCc != null && email.MailCc.Contains(address.Address, StringComparison.InvariantCultureIgnoreCase)) { continue; } if (email.MailBcc != null && email.MailBcc.Contains(address.Address, StringComparison.InvariantCultureIgnoreCase)) { continue; } index.Add(address.Address); result.Add(address); } return(result.Count == 0 ? sourceList : string.IsNullOrEmpty(sourceList) ? PXDBEmailAttribute.ToString(result) : PXDBEmailAttribute.AppendAddresses(sourceList, PXDBEmailAttribute.ToString(result))); }