Full list of methods for COM objects
Asked Answered
L

3

6

I would like to know which functions I can use with RDCOMClient objects.

For example, to create an email we can use

OutApp <- COMCreate("Outlook.Application")
# create an email 
outMail = OutApp$CreateItem(0)

Along with outMail[["subject"]], outMail[["HTMLbody"]] or outMail[["Attachments"]]$Add(filepath)

But how can I get a comprehensive list?

The RDCOMClient doc is out-of date and the functions listed such as getFuncs() and getElements() are not available in the package anymore. Using names() to try and find out what was under the hood gave me no result, and

install.packages("remotes")
remotes::install_github("omegahat/SWinTypeLibs")

gives an error as well. Any idea on how to check Outlook for objects?

Leontineleontyne answered 23/5, 2021 at 3:8 Comment(9)
You can get some idea from the package's NAMESPACE, though that's just a list of exported functions. You can go further and look at each of those function's definitions within the package's ./R/ source directory. You can go up one level and into its ./man/ directory to find its manual packages for the functions. (Given that most files have not been touched in over 10 years, though, in my mind renders assumptions on RDCOM-compatibility a bit risky.)Rajasthan
Thanks but this doesn't allow me to answer my question afaik. I am after the specific methods available for an Outlook email object.Leontineleontyne
(Forgive me one thing: my links in the previous comments are all against the wrong package github dir ... vice killing the comment and retyping it, I'll just post the two links as they should be: NAMESPACE and the package's ./R/ source directory. Sorry about that!)Rajasthan
That (egregious) typo aside, I don't know what to tell you. The package seems to me to be unmaintained/orphaned, and its documentation is out of date. I suggested you can read the source of each file yourself, and I agree that that's certainly an onerous task, so I suspect your only other recourse is to reach out to the package maintainer(s) and see if they can help. Perhaps a new "issue" for updated docs?Rajasthan
Reading the source doesn't look too useful either, as an example the function getCOMElements(outMail) gives could not find function "getExtends". Anyways thanks for your helpLeontineleontyne
Outlook.Application is documented here: learn.microsoft.com/en-us/office/vba/api/outlook.application (with VBA syntax). That has nothing to do specifically with RDCOMClient which is just a utility package to call COM objects. To discover the classes, method and properties by code (possible with Outlook because it has what's called a type library, a .tlb), this seems to be doable using the SWinTypeLibs package.Simile
May be useful: mrexcel.com/board/threads/…Haha
@Haha : that post contains ingenious code but at the ends the post says the code does not give arguments or return values (or their types).Allieallied
This question is now directly answered here: #63992981Grisons
A
4

If you have Outlook, Excel or Word installed then you can do the following ...

  1. Press F11 to get to a Visual Basic Application (VBA) Integrated Development Environment (IDE).
  2. On the menu bar go to Tools->References to prompt the References dialog box.
  3. On the References dialog box, in the Available References checkbox list, page down until you find Microsoft Outlook Library (or similar), once found then check the checkbox and then press OK to confirm selection and dismiss dialog. This adds a reference to the Outlook type library to the current project.
  4. With the Outlook type library referenced (see step (3)) one can now press F2 to show the Object Browser dialog box.
  5. In the Object Browser dialog box, select the top left dropdown list which will probably say <All Libraries> . Change the dropdown so it says Outlook, this will scope the object browser to just the Outlook type library.
  6. You can now browse all the objects in the Outlook type library. Select a class in the Classes pane on the left hand side and the class's methods will appear in the right hand side.

Enjoy!

Allieallied answered 26/5, 2021 at 12:9 Comment(0)
B
4

I am not sure of a way to do this in R, but you should be able to do it in .

I am still learning , but this at the very least gets all the properties and methods of an object:


$ol = New-Object -ComObject Outlook.Application
$new_item = $ol.CreateItem(0)
$new_item | Get-Member

  TypeName: System.__ComObject#{...}

Name                    MemberType     Definition
----                    ----------     --------

HTMLBody                Property      string HTMLBody () {get} {set}
Subject                 Property      string Subject () {get} {set}
Attachments             Property      Attachments Attachments() {get}

There are a lot more than this but I'm actually transcribing from my other computer which has Outlook installed. The Get-Member works on more than just the application object so you can also see the members and properties accessible to the Outlook object itself or other COMS.

It also appears that the VBA resources may be helpful:

https://learn.microsoft.com/en-us/office/vba/api/outlook.application.createitem

Name Value Description
olAppointmentItem 1 An AppointmentItem object.
olContactItem 2 A ContactItem object.
olDistributionListItem 7 A DistListItem object.
olJournalItem 4 A JournalItem object.
.... ... ...

And most importantly:

https://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem

PROPERTIES
---------
Actions
AlternateRecipientAllowed
Application
Attachments
AutoForwarded
AutoResolvedWinner
BCC
BillingInformation
Body
BodyFormat
Categories
CC
...
Bitters answered 26/5, 2021 at 0:36 Comment(0)
A
4

If you have Outlook, Excel or Word installed then you can do the following ...

  1. Press F11 to get to a Visual Basic Application (VBA) Integrated Development Environment (IDE).
  2. On the menu bar go to Tools->References to prompt the References dialog box.
  3. On the References dialog box, in the Available References checkbox list, page down until you find Microsoft Outlook Library (or similar), once found then check the checkbox and then press OK to confirm selection and dismiss dialog. This adds a reference to the Outlook type library to the current project.
  4. With the Outlook type library referenced (see step (3)) one can now press F2 to show the Object Browser dialog box.
  5. In the Object Browser dialog box, select the top left dropdown list which will probably say <All Libraries> . Change the dropdown so it says Outlook, this will scope the object browser to just the Outlook type library.
  6. You can now browse all the objects in the Outlook type library. Select a class in the Classes pane on the left hand side and the class's methods will appear in the right hand side.

Enjoy!

Allieallied answered 26/5, 2021 at 12:9 Comment(0)
J
2

This can somewhat easily be done for Outlook, because every outlook object has a class property.

If you have a given object of COMIDispatch class in R, and it is a reference to an Outlook object, you can use the function class() to retrieve its class and then check the OlObjectClass enumeration for what properties and methods that class has.

A short step by step example:

> # initialise the app
> Outlook_App <- RDCOMClient::COMCreate("Outlook.Application")

In order to find out what we can do with that object, we need to look up the reference. For that, we need its class.

> Outlook_App$class()
[1] 0

So we look up 0 in the OlObjectClass enumeration and find out it's an Application object. Its properties and methods are listed in the referenced link in the OlObjectClass enumeration: Application.

Here, we have access to the methods and properties. For the events, we would need the now defunct packages RDCOMEvents and/or RDCOMServer.

But we can try the method getNameSpace("MAPI") to access some other functionality. We know that we have to use the "MAPI" parameter from the method description linked above.

> Outlook_Namespace <- Outlook_App$getNameSpace("MAPI")

Now, the Namepace object has another class, for which we can look up the object definition and so on and so forth.

Unfortunately this does not work for Excel objects, since they do not have a class property, if anyone knows a solution please contact me.

Jordanjordana answered 20/5, 2022 at 10:8 Comment(2)
The first link is brokenLeontineleontyne
Should be fixed nowJordanjordana

© 2022 - 2024 — McMap. All rights reserved.