Outlook mail automation

Hi every one,
I use the following code to create new outlook subfolder in “Inbox” and receiving the following exception:
System.Runtime.InteropServices.COMException: Cannot create the folder.
Code:
ofolders(“Inbox”).Folders.Add(“afs”,Type.Missing)

Any solution?

1 Like

Hey @afsaneh_keivani

Where are you writing this code ?

Thanks
#nK

in assign activity

1 Like

i tested it In Assign activity as well as get email activity

1 Like

Hey @afsaneh_keivani

Write the above in invoke code please.

Thanks
#nK

I did and still same error.
Have you done this before?

1 Like

Hello @afsaneh_keivani ,

Refer to the below post.

the assembely code :Microsoft.Office.Interop.Outlook is already there in xaml file and still not working.

Thanks

Hey @afsaneh_keivani

Yep, so could you please show what have you done ?

Thanks
#nK

Flowchart.xaml (7.1 KB)

here is the code

1 Like

Hey @afsaneh_keivani

Could you please paste the code piece here only for that interop move you are doing ?

Thanks
#nK

Assign oFolders = oapp.Session.DefaultStore.GetRootFolder().Folders

Invoke code: ofolders(“Inbox”).Folders.Add(“afs”,Type.Missing)

1 Like

Hey @afsaneh_keivani

Kindly try the below,

Microsoft.Interop.Outlook.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Folders.Add("AFS", Type.Missing)

Thanks
#nK

There is compile error with code:
Interop is not member of Microsoft.

Thanks

1 Like

Hey @afsaneh_keivani

Sorry for the syntax error,

Microsoft.Office.Interop.Outlook.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Folders.Add("AFS", Type.Missing)

Missed office, please try now the updated as above

Thanks
#nK

Outlook.OlDefaultFolders.olFolderInbox is not exist

any advise how can i dd it to my project?

thanks

1 Like

@afsaneh_keivani Try below thread

Will share a sample demo !

@afsaneh_keivani Try the below workflow

Outlook.zip (2.7 KB)

Also, I am tried to create a test folder inside inbox. You can change the folder names code within in the assign activity of Add Folder sequence

oFolders("Inbox").Folders.Add("test",Type.Missing)

Also, try adding below assembly to your xaml

Capture

i did a minor change Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox and it worked

Thank you very much @Nithinkrishna

1 Like