Outlook VBA - Function to retrieve Display Name of an email address - vba

Apologize as I come up without any code, I just simply don't know how to start.
So let say I have an email address. I want to check whether this email address belongs to any contact in any contact folder or in any address book of my Outlook. If yes, I want to retrieve the associate Display Name of the email address. I need the function fast enough to check long list of email addresses.
Hope somebody can help. Thanks.

Try to call Namespace.CreateRecipient / Recipient.Resolve, then read Recipient.Name property. Note that it is not unique.
If you need to resolve multiple entries, create a temporary message, add the values to the MailItem.Recipients collection, call Recipients.ResolveAll.

Related

FROM Name MailItem Property

I am trying to record tasks via sending an email in Outlook and I need to have the sender name in the body so the others know the task is assigned to them.
Using MailObj.SenderName does not use the FROM name it would look for the name of the recipient if I was replying.
If you want the current user information, use Application.Session.CurrentUser.

IN VBA is it possible to get the recall message target?

Using the mail object properties I can get information about a recall message, but I don't know how to grab the information about the message it is going to remove.
The body gives the subject, but the emails being recalled in my case are not unique in sender nor in subject and so a combination of values for the target message are needed to unique them.
Thanks for your help and time,
Outis
Outlook uses EntryID property values to identify their items uniquely. Here is what MSDN states:
A MAPI store provider assigns a unique ID string when an item is created in its store. Therefore, the EntryID property is not set for an Outlook item until it is saved or sent. The Entry ID changes when an item is moved into another store, for example, from your Inbox to a Microsoft Exchange Server public folder, or from one Personal Folders (.pst) file to another .pst file. Solutions should not depend on the EntryID property to be unique unless items will not be moved.
Also you may consider adding your own ID as a user property.

Add link to contacts in outlook Appointment Module Form using custom fields

I'm a long date leecher of this site... this is the first time I'm not able to find a response (Google didn't help too).
Well, what I am trying to do is to add an active link to a contact to a custom field in an Appointment Module Form.
I can put the address I want in the appointment custom fields using this code (vb.net):
Dim extendedPropertyDefinition = New ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "MyField", MapiPropertyType.String)
item.SetExtendedProperty(extendedPropertyDefinition, "address#iwant.com")
I am able to view MyField using a custom field in my Appointment Module Form.
Setting "To" field to the value (in custom field properties) i can transform the e-mail into the corresponding contact name (obviously if it exists in contacts list).
Here comes the trouble:
I would like to add a link to contact card when clicking the contact name.
I don't really know if it is even possible...
Thank you very much for any help... "It is not possible" will be an appreciated response too.

How to find owner of a shared calendar in appointment and meeting window?

There is no field in the appointment Item or the meeting item that determines the current calendar which i am accessing is shared calendar or my own calendar folder?
How do i get this? Is there is a way in outlook object model to get this?
You can access the meetingItem.Parent.StoreId (not the AppointmentItem, I believe). What you get then is a HexId string that, if converted to a plain text string, contains the MS Exchange account name after /cn= (I think at the end of the string).
With that name, you can do a CreateRecipient(thatName) and Outlook.Recipient.Resolve() it.
After that, you can access the name of the account by using recipient.Name
Sorry, I tried to paste code in this answer, but it didn't work as expected and took too long. Please ask if you need more directions.

How can retrieve email address from the Infopath people/Group picker

How can retrieve email address from the Infopath people/Group picker?When I add the people/Group picker into the infopath form, I only get 3 fields DisplayName,AccountId,AccountType.Can anyone show me how can I get the email either by configurations or by code.
In SharePoint Designer, when setting up a workflow to respond to an InfoPath people picker field, I simply map the "TO:" field of my "Send Email" action to whatever people picker field I have (even if it's set to pull the Display Name)... and the email will successfully send out regardless. Now, your mileage may vary and perhaps it's due to our Exchange server settings and small company size which allows this to work.
Anyways, try it out. Maybe extracting an email address from the people picker is a superflous step.
I have a simpler solution.
Assume you are using the connection wizard to send an email to a person selected from a people picker.
in the to field -
concat(substring-after(AccountId, "\"), "#domain.com")
assuming your companies mail accounts have an entry for username # domain.
because AccountId = domain\username
so we end up with username#domain.com
Worked for me
Create a button and the following rules for that button.
Create a data Connection to retrieve from GetUserProfileByName.
Create a field to store the email you are retrieving.
Rules for the button
Rule 1 Set a fields value. Set the value of the AccountName of GetUserProfileByName to equal the AccountID from the people picker.
Rule 2 Add an Action to to Query the Data Connection GetUserProfileByName
Rule 3 set a fields value to the email address of the query you just performed
Filter Data
Change value to name
If you simply want to populate a field with the email address from your domain this works perfectly. I have been banging my head on the double eval trick for two days. I got it to work but the form rendering in SharePoint took 2 minutes and 46 seconds.
I know this is too late for the answer but still i am writing this so that someone can get help in future.
When we keep People picker it gives us three values which you specified (AccountId, DisplayName and AccountType).
Now if some one wants to retrieve the email address, there may be so many requirement but i guess most of the person want to send mail to the user which are selected into people picker.
If you want to send mail to selected user then you can just use AccountId field into your workflow item. SharePoint designer automatically detect the email address from the AccountId and sends the mail.
I hope this might save someone's time.