How to Cast during Assign Object ->

I am using _Application.CreateItem(0) method to create new mail item resulting Object type - i am not able to assign this created item to mailItem variable.

Please see my workflow and give me advice how to cast my Object to Mailitem. (I need to invoke Display method afterwards, therefore i need to store mailitem in specific object type.Main.xaml (5.4 KB)


1 Like

in company policy, we cannot invoke Code in RPA

VB.NET code as follows works fine in invoke code

Dim outApp As New Microsoft.Office.Interop.Outlook.ApplicationClass
Dim outMailItm As Microsoft.Office.Interop.Outlook.MailItem = CType(outApp.CreateItem(0), Microsoft.Office.Interop.Outlook.MailItem)
outMailItm.SentOnBehalfOfName = “test”

Main.xaml (5.1 KB)

How can i rewrite this simple code into sequence of Assign acitvities and Invoke Method activities please? There is some problem in importing namespaces it seems.


Any update to this? UiPath still does not allow this functionality. 2020.10.2.

No compiled code to run
error BC30512: Option Strict On disallows implicit conversions from ‘Object’ to ‘Microsoft.Office.Interop.Outlook.MailItem’.

Sample Code - [RESOLVED][Outlook] How to send email-VBForums
Dim MSO As New Microsoft.Office.Interop.Outlook.Application
'Create a new Message object
Dim msg As Microsoft.Office.Interop.Outlook.MailItem

    'Compose the Message
    msg = MSO.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
    msg.Subject = "This is an example message"
    msg.To = ""

    'This parameter just has to point to a valid file
    'If you have SendOnBehalf permissions, you can specify a SOB user
    'msg.SentOnBehalfOfName = "Some Other User"
    ''Create an HTML formatted body
    'Dim body As String
    'body = "<h1>This is an HTML Email</h1><p>Hello, here is a test message.</p>"
    ''Set the body format and contents
    'msg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML
    'msg.HTMLBody = body

    'Send the message