• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Lookup a Contact's time zone

Slipstick Systems

› Developer › Lookup a Contact’s time zone

Last reviewed on February 13, 2018     11 Comments

DigitalDawn had this question on Outlook Forums:
Is there an Outlook Add-In that can tell you the time or time zone for a contact based on their area code?

I'm not aware of any addins, but it's a great idea. Until then, adding a field to contacts to record the time zone is one option, although you'd need to add the time zone yourself.

You can use a macro to grab the postal code and look up the time zone. While it's not perfect, it is useful for anyone who wants to identify the time zone a person lives in.

Use VBA to Map an Outlook Contact's Address

I think using the postal code would be better than the phone number's area code, at least here in the US. Thanks to number portability, the person may not be living in the same region the area code is assigned to.

The following two URLs work for US addresses. Any site that includes the zip code in the URL can be used. To use, replace the number with the zip code string. Melissadata's URL accepts the full telephone number or just the area code, if you prefer to use it.

https://www.melissadata.com/lookups/ZipCityPhone.asp?InData=12345&submit=Search
//www.zip-info.com/cgi-local/zipsrch.exe?tz=tz&zip=12345&Go=Go

At this time, the code opens a web page containing the time zone and other information.

results from melissadata

I'm working on scraping the page and grabbing just the time zone from the page, then displaying it in a message box, writing it to the notes field, or to a custom field.

To use, select a contact and run the macro.

Get the time zone macro

Sub GetContactTimeZone()
   
  Dim strURL As String
  Dim oApp As Object
  Dim strAddress As String
 
  Set oApp = CreateObject("InternetExplorer.Application")
 
If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
 Set oContact = ActiveExplorer.Selection.Item(1)
 
strAddress = oContact.MailingAddressPostalCode

ReplaceSpaces strAddress
strURL = "//www.melissadata.com/lookups/ZipCityPhone.asp?InData=" & strAddress & "=Search"

 
oApp.Navigate (strURL)
oApp.Visible = True
 
'wait for page to load before passing the web URL
Do While oApp.Busy
  DoEvents
Loop
 End If
 
 
Set oApp = Nothing
End Sub
 
 
Private Sub ReplaceSpaces(strAddress As String)
  strAddress = Replace(strAddress, " ", "-")
End Sub

How to use macros

First: You will need macro security set to low during testing.

To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More Information

More information as well as screenshots are at How to use the VBA Editor

Lookup a Contact's time zone was last modified: February 13th, 2018 by Diane Poremsky

Related Posts:

  • Map Contact Addresses or Meeting Locations
  • View Messages in Internet Explorer using a macro
  • Open a Webpage when a Task Reminder Fires
  • Categorize Contacts with bad addresses

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
11 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Pandu
September 12, 2016 8:56 pm

Unable to see my query here. Did you receive my query? If yes, can I have update?

0
0
Reply
Diane Poremsky
Author
Reply to  Pandu
September 12, 2016 9:17 pm

comments stay in moderation until i have time to answer the questions, otherwise i tend to lose them.

1
0
Reply
Pandu
September 12, 2016 4:23 pm

Hi Diana,

I have couple of queries:

1. I need to retrieve the exact time zone of each recipients (not a lookup in a web page) to do some calculations based on Time Zone in VBA. Is there a way to get this?

2. I want to fire ItemSend event only for meeting request related items like Skype Meeting, Appointment, Meeting. Currently I placed this event in ThisOutlookSession. How can we do this?

3. Once we successfully code for a desired outlook requirement, and if we want to host it in many systems, what is the best way of doing it? Macro code has to place in each and every system? If yes, can we do it with a one click executable like add-in feature?

Can you please suggest?

Appreciate your quick help on this.

0
0
Reply
Diane Poremsky
Author
Reply to  Pandu
September 12, 2016 9:23 pm

1. where are you going to find the TZ? If you have the time zone, you can work with it, but outlook doesn't store the time zone anywhere - you would need to either look it up somewhere or create a custom time zone field to store it.

2. You'll use if statements if you want to limit when it runs. If you only want it to run for meetings, use something like if typeof(item) = meetingitem then...

3. compiling it into an addin is the best way to install it on multiple systems.

0
0
Reply
Pandu
Reply to  Diane Poremsky
September 13, 2016 2:08 pm

Thanks for the quick response. Here is further queries on above 3: #1: My requirement is to show a message with color bar, when we are trying to send a meeting invite to recipients who are out of business hours. I was able to handle color bar with categories + added confirmation box on send click via Outlook Itemsend event for a meeting item. But recipients could be in different time zone (to know their business hours), I am looking for ways to resolve this. In Outlook 2016 options, we have an option to select time zones (under calendar tab), when we change this tz, then, its reflecting in the "Open Contact Card". I am not sure whether we can get the details of this? If this is not possible, then, we need to lookup as shown in this article, but how to get only tz value (instead of showing the entire web page, which is not needed in my case) back to the outlook VBA code (for later calculations)? Sample code will help me. #2: This is resolved by adding If condition Item.Class = olMeetingRequest on ItemSend. Thanks. #3: Can you please help me on steps to create "ThisOutlookSession"… Read more »

0
0
Reply
Diane Poremsky
Author
Reply to  Pandu
September 14, 2016 12:12 am

#1 i don't have any code samples - you'll probably need to use a different site and will need to use aspx or a web service to grab the time zone.

#3 if you are just passing out the macros, you don't need to do anything fancy - but everyone will need to install the macros. if you turn it into an addin, then it can be installed using logon scripts or with a button click. This requires visual studio.

#4 you get the start time from the start field but i'm not sure why you need it when you send messages - the start time would be set before its sent.

#5 excel vba code samples can usually be hijacked to work in outlook. depending on what you need it for - datediff might work - DateDiff("n", "6:45", "7:30") / 60 - this would get you the minutes (use variables for the time).

1
0
Reply
Pandu
Reply to  Diane Poremsky
September 20, 2016 3:57 pm

Thanks for the response Diane.

I am able to get city of a recipient (as below) but not the country/region. How to get country details via VBA.
recipient.AddressEntry.GetExchangeUser.City

0
0
Reply
Diane Poremsky
Author
Reply to  Pandu
September 20, 2016 10:28 pm

It doesn't look like country is exposed -
https://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.outlook.exchangeuser_members.aspx

you can get officelocation (assuming its filled in) or state.

0
0
Reply
Pandu
Reply to  Diane Poremsky
September 13, 2016 8:20 pm

One more:
6: In this article you are retrieving the address based on contactitem (as shown below), but I should retrieve the address of the recipients in the meeting request (on meeting request send event). How can we get this details? I checked the item properties (in debug mode of ItemSend event) and I didn't find any address for the recipients. Can you please suggest.

If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
Set oContact = ActiveExplorer.Selection.Item(1)
strAddress = oContact.MailingAddressPostalCode

Sample code for all my queries will really help.

0
-1
Reply
Diane Poremsky
Author
Reply to  Pandu
September 14, 2016 12:26 am

This macro shows how to look up a contact using the email address - https://www.slipstick.com/developer/categorize-messages-using-contact-category/

1
-1
Reply
Cathy
August 1, 2013 11:59 am

This is exactly what I was looking for, well, almost exactly. I can't wait to for the update that gets the value instead of getting the web page. Thanks again!!!

1
-1
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 33

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment