private IRecipient CreateRecipient(IRecipients recipients, string decoded) { // First try to resolve directly IRecipient recipient = recipients.Add(decoded); if (recipient.Resolve()) { return(recipient); } // Nope, remove and create with email recipient.Dispose(); recipient = null; recipients.Remove(recipients.Count - 1); string displayName; string email = ParseBCCHeader(decoded, out displayName); // TODO: is it possible to use the display name? recipient = recipients.Add(email); recipient.Resolve(); return(recipient); }
public IRecipient ResolveRecipient(string name) { using (ComRelease com = new ComRelease()) { NSOutlook.NameSpace session = com.Add(_app.Session); // Add recipient, unlock after Resolve (which might throw) to wrap NSOutlook.Recipient recipient = com.Add(session.CreateRecipient(name)); if (recipient == null) { return(null); } IRecipient wrapped = Mapping.Wrap(com.Remove(recipient)); wrapped.Resolve(); return(wrapped); } }