cancel
Showing results for 
Search instead for 
Did you mean: 

Graph API Outlook - Inconsistencies in SendMail-function

til.minet
Level 5
Hello community,

We recently established our app registration and are getting ready to use the Graph API objects from the DX. I started to experiment with the Graph API Outlook VBO and found the following issues. I am a little worried that I just scratched the surface.

There are three different requests that allow me to send or prepare e-mail-messages. "Send Mail", "Create Message" and "Create Message in Folder".

I suppose "Send Mail" would be one of the actions most commonly used. The input parameters allow me to define a body content - but I cannot choose if I want to send the body as text or HTML. The parameter has no description and I can only find out what content is expected by looking in the Web API definition. If I want to send an e-mail in HTML, which we mostly did with the Outlook VBO. Even worse: There is a parameter "saveToSentItems" in the request body which is also hard-coded. The description of the Send Mail-action tells me that the message is saved in "Sent Items" by default. Too bad that this parameter is hard-coded as "false" in the request body.

To my understanding it should be possible to choose the content type as an input parameter. Same for saveToSentItems.
7871.png

Next action is "Create Message". Same story, but the content type is hard coded as "HTML". No description about that either.

7873.png


And, to sum this up, "Create Message in Folder". From my understanding this should at least behave the same way as "Create Message", but see for yourself - hard coded body content as text again.
7875.png

Do I misunderstand something or is there still room for optimization in this API definition? With these mistakes in even the most basic actions I tend to get the feeling that it might be easier and less frustrating to create the whole definitions myself.

Does anybody have more experience with the other assets? Are the other ones more usable than this one?

Best regards
Til

------------------------------
Til Minet
RPA Developer
EWE AG Germany
Oldenburg
------------------------------
30 REPLIES 30

@Sheabin George,

Are you passing an empty Collection into the Attachment input or leaving the value blank? I just tested the solution with no attachments (as pictured) and it worked fine.

7648.png
Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

@ewilson

Correct, deleting the data input on the Send Mail action works however, we are trying is a templatized process for emails depending the automation process.
This field will need to be a dynamic.

So when I passed it with the collection values as blank, it throws the exception.
Will a modification need to happen to the Common Code under the API? Or under SendMail Request custom code?

Thanks,​

------------------------------
Sheabin George
------------------------------

@Sheabin George,

Replace the code in the Body Content portion of the Send Mail -> Request section with the following code:
// Create a new SendMailRequest instance and set the properties using our input values.
// NOTE: Empty collections (ex. BCC Addresses) will not be included in the serialized JSON.
SendMailRequest req = new SendMailRequest();
req.Message = new Message();
req.Message.Subject = Email_Subject;
req.Message.Body = new Body
			{
			  ContentType = Email_Body_Content_Type,
			  Content = Email_Body_Content
			};
req.Message.ToRecipients = ConvertAddressCollectionToList(To_Addresses);
req.Message.CcRecipients = ConvertAddressCollectionToList(CC_Addresses);
req.Message.BccRecipients = ConvertAddressCollectionToList(BCC_Addresses);

if ((File_Attachments != null) && (File_Attachments.Rows.Count > 0))
  req.Message.Attachments = AttachFiles(File_Attachments);
else
  req.Message.Attachments = null;
	
req.SaveToSentItems = Save_to_Sent_Items_Folder.ToString().ToLower();

// Set Request_Content to the serialized object instance.
Request_Content = JsonConvert.SerializeObject(req, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
​


Cheers,



------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

@Sheabin George,

Looking into this a bit further, the original code works fine even with an empty Collection (no rows). Does your Collection have a row with no data in the actual fields? Can you post a picture of the actual Collection definition and the Initial Values tab?

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

@ewilson,

I tried the code above and ran into the same issue.

Here are the screen shots you requested:

7678.png7679.png
Thanks,

------------------------------
Sheabin George
------------------------------

@Sheabin George,

Is there a reason you have an empty row in the attachments collection?​ If not, remove it and both sets of code will work as expected.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hi @ewilson

Late to the party here but I am trying to get the Graph API set up in the dev environment and could comply just use some help with how the Send Mail function works. A previous team set up the API infrastructure and as it stands I have the following inputs for the send mail function:

7693.png
The body of the Send Mail Request simply states [Message JSON]
I have been told I need to generate the JSON using the JSON collection action but I don't even know what to include in the collection!

Thanks in advance



------------------------------
Elliot Barling
------------------------------

Hi @Elliot Barling,

It looks like you're trying to use the Microsoft Graph - Users asset. If you need to send email I'd suggest you switch to using the Microsoft Graph - Outlook asset instead.​ While the Users object will work it is less refined than the Outlook object.

To answer your specific question, any time you see a reference to entering a JSON object/blob the expectation is that you'll look at the specific API reference. In this case that means the Microsoft Graph v1 API Reference. You can find details of the Message object at the following link:

https://docs.microsoft.com/en-us/graph/api/resources/message?view=graph-rest-1.0

Scroll to the bottom of the page and you'll find the an example of the overall JSON definition. An important thing to remember is that not all of what's shown in required. This is another reason why using the Microsoft Graph - Outlook object is a better choice.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Thanks @ewilson

How would I get hold of the Microsoft Graph - Outlook asset?
Apologies, absolute novice with this Graph stuff!

Thanks
Elliot​



------------------------------
Elliot Barling
------------------------------

@Elliot Barling,

Always check the Digital Exchange first for any assets. If you're not familiar with the DX, it's our online marketplace. Pretty much everything Blue Prism puts out (software and connector-wise) can be found on the DX.

https://digitalexchange.blueprism.com/dx/entry/3439/solution/microsoft-graph-api---outlook

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------