-
Dec 23rd, 2020, 06:11 PM
#1
Thread Starter
Hyperactive Member
Create OutlookFolder
Ok, this may not be strictly VB.net however I am hoping someone can help
In VBA - outlook I am trying to create a folder directly under the high level account name (not the in box or Drafts etc. but at the same level)
the code I have is :-
Code:
Dim oloUtlook As Outlook.Application
Dim ns As Outlook.NameSpace
Dim itm As Object
'On Error Resume Next
'Application.ScreenUpdating = False
Set oloUtlook = CreateObject("Outlook.Application")
Set ns = oloUtlook.GetNamespace("MAPI")
Set itm = ns.GetDefaultFolder(olFolderInbox)
itm.Folders.Add ("aaaa")
Set oloUtlook = Nothing
Set ns = Nothing
Set itm = Nothing
MsgBox "Outlook Set Up Succesfully"
ThisWorkbook.Close
End Sub
The problem is how do I get it to create the folder at the same level as in box etc, not underneath it as there has to be a GetDefaultFolder and the only allowable values are inbox, drafts etc.
Last edited by Signalman; Dec 23rd, 2020 at 06:15 PM.
-
Dec 23rd, 2020, 06:52 PM
#2
Re: Create OutlookFolder
Our 'Office Development/VBA' forum is more appropriate for this question, so I've moved the thread there.
-
Dec 23rd, 2020, 07:01 PM
#3
Thread Starter
Hyperactive Member
Re: Create OutlookFolder
Ok i think i have got it to work, by chance. - for reference for others.
replacing the
Code:
Set itm = ns.GetDefaultFolder(olFolderInbox)
with
Code:
Set itm = ns.folders("mailbox name")
-
Dec 24th, 2020, 05:36 AM
#4
Re: Create OutlookFolder
there are a couple of options, by default the parent name is personal folders, but the safest in case the of any other name, would be
Code:
Set itm = ns.GetDefaultFolder(olFolderInbox).parent
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|