Create Exchange MailBox Folder - Converting VB.Net Code to Workflow

Hi All,

I have the following code snippet to create a folder in the exchange server by checking whether it exists or not.

But I would like to convert this to a workflow instead of using it as a plain VB.Net Code and using Invoke code activity.

Not able to identify proper/matching activity to accommodate the below lines from the code snippets.

Dim strAutodiscover As String = "emailToBeUsed"
        Dim strFolderName As String = "FodlerNameToBeCreated"
        Dim strUserName As String = "username"
        Dim strPassword As String = "password"

        Dim service As ExchangeService = New ExchangeService(ExchangeVersion.Exchange2013_SP1)
        service.Credentials = New WebCredentials(strUserName, strPassword)

        service.TraceEnabled = True
        service.TraceFlags = TraceFlags.All

        Dim view1 As FolderView = New FolderView(100)
        view1.PropertySet = New PropertySet(BasePropertySet.IdOnly)
        view1.Traversal = FolderTraversal.Deep
        Dim findFolderResults As FindFoldersResults = service.FindFolders(WellKnownFolderName.Root, view1)

        Dim blnFolderExist As Boolean
        For Each f As Folder In findFolderResults
            If f.DisplayName.Equals(strFolderName, StringComparison.OrdinalIgnoreCase) Then
                blnFolderExist = True
            End If

        If Not blnFolderExist Then
            Dim folder As Folder = New Folder(service)
            folder.DisplayName = strFolderName
            Dim ParentFolder As FolderId = New FolderId(WellKnownFolderName.Inbox, strAutodiscover)
            ' Create the New folder in the specified destination folder.
        End If

@Pablito, @loginerror Any help with this?

Hi @sarathi125

There is the Invoke Method activity that might be used here I think, if I got it right.

HI @loginerror ,

You are correct, but I am not sure in the Invoke Method activity which option to be used for this.

1 Like

You will have to figure it out for your specific use-case. Here is a sample on how to use it to add a new item to a List of String:

1 Like

@loginerror ,

I have fixed it by adding 3 Invoke Method activities and it is working.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.