I am developing code for capturing photo/picture for the recipient, while sending an email in the sending even of MS outlook. Can you please suggest what is the best way to achieve it?
> Outlook.NameSpace outlookNameSpace = this.Application.GetNamespace("MAPI");
Outlook.MAPIFolder contactsFolder =
outlookNameSpace.GetDefaultFolder(
Microsoft.Office.Interop.Outlook.
OlDefaultFolders.olFolderContacts);
Outlook.Items contactItems = contactsFolder.Items;
try
{
Outlook.ContactItem contact =
(Outlook.ContactItem)contactItems.
Find(String.Format("[FirstName]='{0}' and "
+ "[LastName]='{1}'", "firstName", "LastName"));
if (contact != null)
{
contact.Display(true);
}
else
{
MessageBox.Show("The contact information was not found.");
}
}
catch (Exception ex)
{
throw ex;
}
In the try block, contact is null. Let us know what I am doing wrong.
Thanks in advance
Of course, I very much doubt anybody would have a contact with the first name of "firstName" and last name of "LastName" - that is what your code is searching for.
Extract the sender email address and search for contacts with a matching Email1Address, Email2Address, or Email3Address.