RDOWeatherServices object

 

RDOWeatherServices object represents the list of weather locations shown in the Calendar folder by Outlook 2013.

It can also be used in any other version of Outlook (or standalone version of MAPI) to retrieve weather conditions at a particular location.

 

Returned by:

RDOSesssion.WeatherServices

RDOStore2.WeatherServices

 

See also: RDOWeatherLocations, RDOWeatherLocation, RDOWeatherConditions, RDOWeatherForecastCollection, RDOWeatherForecast

 

The example below retrieves the weather locations shown by Outlook 2013.

 

'enumerate all existing weather locations

set Session = CreateObject("Redemption.RDOSession")

Session.MAPIOBJECT = Application.Session.MAPIOBJECT

for each objLocation in Session.WeatherServices.Locations

  Debug.Print objLocation.Name

next

 

The example below displays the weather conditions for the current user (RDOSesssion.CurrentUser).

 

set Session = CreateObject("Redemption.RDOSession")

Session.MAPIOBJECT = Application.Session.MAPIOBJECT

set CurrentUser = Session.CurrentUser

strCity = CurrentUser.City

if strCity <> "" Then 'we need to have at least the city for the weather

  strState = CurrentUser.StateOrProvince

  strCountry = CurrentUser.Country

  strLocation = strCity

  if strState <> "" Then strLocation = strLocation & ", " & strState

  if strCountry <> "" Then strLocation = strLocation & ", " & strCountry

  set WeatherServices = Session.WeatherServices

  set locations = WeatherServices.ResolveLocation(strLocation)

  if locations.Count = 0 Then

    MsgBox "Unable to resolve location " & strLocation

  Else

    'todo: check if there is more than one match

    set objLocation = locations(1)

    'if the location is not yet added to list of locations in the current mailbox, add it (but we don't have to do that)

    if (WeatherServices.Locations.Item(objLocation.Code) Is Nothing) Then

      WeatherServices.Locations.Add(objLocation)

      WeatherServices.Save

    End If

    'display the current weather for the mailbox owner

    set CurrentConditions = objLocation.GetCurrentConditions

    strCurrentWeather = "Weather for " & CurrentConditions.LocationName & vbCrLf & _

                        "Temperature: " & CurrentConditions.Temperature & vbCrLf & _

                        "Wind: " & CurrentConditions.WindDisplay & vbCrLf & _

                        CurrentConditions.SkyText & vbCrLf

    for each objForecast in CurrentConditions.Forecast

      strCurrentWeather = strCurrentWeather & vbCRLF & _

                          objForecast.Day & " (" & objForecast.Date & ")" & _

                          ". Low: " & objForecast.Low & ", High: " & objForecast.High & ", " & _

                          objForecast.SkyText

    next

    MsgBox strCurrentWeather

  End If

End If

 

 

Properties

Methods

 


Derived from: IDispatch


PrProperties


Enabled
Boolean, read/write.
True if the Weather bar in Outlook 2013 is enabled.

 
LanguageCodeID
Language code id (see RFC4646), string, read/write.
Specifies the language to be used for resolving locations and the returned string data.

Note that not all LCIDs are supported.
Example: "en-us" or "de-de".

'resolve a weather location name

strLocationToAdd = "Санкт Петербург"

set Session = CreateObject("Redemption.RDOSession")

Session.MAPIOBJECT = Application.Session.MAPIOBJECT

set WeatherServices = Session.WeatherServices

WeatherServices.LanguageCodeID = "de-de" 'return data in German

set locations = WeatherServices.ResolveLocation(strLocationToAdd)

Debug.Print "Found " & locations.Count & " matching locations for " & strLocationToAdd

Locations
RDOWeatherLocations collection, read-only.
Returns the collection representing the locations specified in the current store.

'enumerate all existing weather locations

set Session = CreateObject("Redemption.RDOSession")

Session.MAPIOBJECT = Application.Session.MAPIOBJECT

for each objLocation in Session.WeatherServices.Locations

  Debug.Print objLocation.Name

next

SelectedLocation
RDOWeatherLocation, read/write.
Returns or sets the selected location on the Weather Bar in Outlook 2013

 
TemperatureUnits
Temperature units to be used when retrieving the weather conditions (see RDOWeatherConditions and RDOWeatherForecast objects).

Can be one of the rdoTemperatureUnits enums:
Celsius = 0
Fahrenheit = 1
 

Methods


ResolveLocation(Name)

Resolves the string given as the parameter and returns a collection of RDOWeatherLocation objects (RDOWeatherLocations).

Name - string, the name of the location

'resolve a weather location name and add it if it does not yet exist

strLocationToAdd = "Санкт Петербург"

set Session = CreateObject("Redemption.RDOSession")

Session.MAPIOBJECT = Application.Session.MAPIOBJECT

set WeatherServices = Session.WeatherServices

WeatherServices.LanguageCodeID = "de-de" 'return data in German

set locations = WeatherServices.ResolveLocation(strLocationToAdd)

Debug.Print "Found " & locations.Count & " matching locations for " & strLocationToAdd & ":"

for each objLocation in locations

  Debug.Print objLocation.Name

next

if locations.Count > 0 Then

  set objNewLocation = locations(1) 'pick the first location

  if (WeatherServices.Locations.Item(objNewLocation.Code) Is Nothing) Then

    Debug.Print "Adding location " & objNewLocation.Name

    WeatherServices.Locations.Add(objNewLocation)

    WeatherServices.Save

  End If

End If

 

Save
Saves the list of location.
See the example above