Issue in running VB Script to send Mail

Hi Everyone,
I’m facing an issue with VBA code i want to send a outlook mail in encrypted format through VBA code but when i use in UiPath it is throwing an error. I’m attaching my code below.
Note: I’m not sure whether my VB script is correct or not. I have basic knowledge on VBA.

Main.xaml (7.1 KB)

MailVBA.txt (687 Bytes)

Hi @user928 , can you provide error details?

Hi @user928,

from your code it looks like, There is one error in the code:

oMail.BodyFormat = olFormatEncrypt

The error is that the constant olFormatEncrypt is not defined or declared. The correct constant to use for encrypted email is olEncrypted.

The line should be modified to:

oMail.BodyFormat = olEncrypted

After this modification, the code should work correctly.

If not works, kindly provide your error details.

Hi @ABHIMANYU_THITE1 i did that modification but still i’m getting validation error.

I have attached same code UiPath Xaml in my question. If you have time please have a look on that.

Hi @user928 ,

You can do two things either change setting of the project turn off the option strict OR make changes in the code.

  • turn off the option strict
  1. Open your UiPath project in UiPath Studio.
  2. In the Project panel, click on the gear icon to open the Project Settings.
  3. In the Project Settings window, select the “Settings” tab.
  4. In the “Settings” tab, scroll down until you find the “VB.Net” section.
  5. In the “VB.Net” section, find the “Option Strict” setting and change it to “Off”.
  6. Click “Save” to save your changes.


  • Changes in the Code, below thing explain you early binding and late binding.

late binding like this:

Dim obj As Object
obj = CreateObject("SomeCOMObject")

You can use early binding like this:

Dim obj As SomeCOMObject
obj = New SomeCOMObject()

You have create code with Late Binding, need to change with early binding

Hi @ABHIMANYU_THITE1 , i tried i don’t know how to set it exactly. If possible can you modify my code and share. That will be a great help because i don’t know Vb scripting.

MailVBA.txt (687 Bytes)

Why don’t you just set Outlook to encrypt the emails and then use the Send Outlook Mail Message activity?

Hi @postwick There is a challenge here for me. i should not send all mails in Encrypted format only specific type of mails i need to send in Encrypted format. I don’t think so it may not be useful.

1 Like