Code Invoking Issues

Hi all,

I am looking to get some help with invoking code in UiPath; Vb.net.

I have written the code in the VS and it works fine:

Module Module1

Sub Main()
    Dim File As String
    Dim OlApp As Object
    OlApp = CreateObject("Outlook.Application")

    File = "C:\Users\greavesj\Desktop\Projects\Test\AP Process\Email_Attachment_Temp\Email Attachments\Test - Embedded PDF.msg"

    Dim Email = OlApp.CreateItemFromTemplate(File)

    For Each Attachment In Email.Attachments
        If Attachment.FileName().Contains(".pdf") Then
            Attachment.SaveAsFile("C:\Users\greavesj\Desktop\Projects\Test\AP Process\Email_Attachment_Temp\Email Attachments\" & Attachment.FileName())
        Else
        End If

    Next
End Sub

End Module

**Code in UiPath:
Dim File As String
Dim OlApp As Object
OlApp = CreateObject(“Outlook.Application”)

    File = "C:\Users\greavesj\Desktop\Projects\Test\AP Process\Email_Attachment_Temp\Email Attachments\Test- Embedded PDF.msg"

    Dim Email = OlApp.CreateItemFromTemplate(File)

    For Each Attachment In Email.Attachments
        If Attachment.FileName().Contains(".pdf") Then
            Attachment.SaveAsFile("C:\Users\greavesj\Desktop\Projects\Test\AP Process\Email_Attachment_Temp\Email Attachments\" & Attachment.FileName())
        Else
        End If

    Next

Issues:

image

@Jimmy_Greaves
have a check if the validation errors get reduced by:

on top define:
Dim Email As Object

More down in the code change: Dim Email into Set Email

Similar do it on other Dims without Datatype definitions and use Set for init the objects

Just refer to some working code lines e.g. like here:

Had a look at some of these things, main issue at the moment is Option Strict configuration, any ideas how to explicitly reference the data types? I am new to coding so I have had only dealt with vb.net in VS

the option strict message comes from missing datatype declaration
grafik

As mentioned above add it to the declaration:
grafik

with looking to the code samples you will find some helping lines and can reduce the validation messages step by step