Hello All,
So I feel like this should be relatively, easy but really have been struggling on the syntax. I currently have a functioning Excel macro to create a folder in my Outlook Inbox, but what I really need to do is create it in my .pst file folder structure since our Outlook storage is insufficient to just use the normal Outlook email inboxes for storage needs.
My .pst file is named Local Email and I would specifically want to add to the Sub Folder Local Email/RFQs/ZZZ - Non RFQ Customers
The file location fopr the .pst file is C:\Local Email File
I know my issue centers around the GetDefaultFolder(olFolderInbox) part but I cannot figure out how to change to the .pst
Also, I would highly prefer to keep this within Excel so it is non user specific and I do not need to modify others Outlook code.
Sub CreateCustomerEmailFolder()
'Purpose - Creates folder in Email Folder for Customer Name
Application.ScreenUpdating = False
If ActiveCell.Column <> 2 Then
MsgBox ("Starting Column must be B, macro aborted!!")
Exit Sub
End If
If Selection.Value = "" Then
Exit Sub
End If
Const olFolderInbox As Long = 6
Dim OutlApp As Object
Dim a(), x
Dim IsCreated As Boolean
' Use already open Outlook application if possible
'On Error Resume Next
Set OutlApp = GetObject(, "Outlook.Application")
If Err Then
Set OutlApp = CreateObject("Outlook.Application")
IsCreated = True
End If
CustName = Selection.Value
With OutlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
FoldName = CustName
.Folders.Add FoldName
End With
If IsCreated Then OutlApp.Quit
Set OutlApp = Nothing
End Sub
So I feel like this should be relatively, easy but really have been struggling on the syntax. I currently have a functioning Excel macro to create a folder in my Outlook Inbox, but what I really need to do is create it in my .pst file folder structure since our Outlook storage is insufficient to just use the normal Outlook email inboxes for storage needs.
My .pst file is named Local Email and I would specifically want to add to the Sub Folder Local Email/RFQs/ZZZ - Non RFQ Customers
The file location fopr the .pst file is C:\Local Email File
I know my issue centers around the GetDefaultFolder(olFolderInbox) part but I cannot figure out how to change to the .pst
Also, I would highly prefer to keep this within Excel so it is non user specific and I do not need to modify others Outlook code.
Sub CreateCustomerEmailFolder()
'Purpose - Creates folder in Email Folder for Customer Name
Application.ScreenUpdating = False
If ActiveCell.Column <> 2 Then
MsgBox ("Starting Column must be B, macro aborted!!")
Exit Sub
End If
If Selection.Value = "" Then
Exit Sub
End If
Const olFolderInbox As Long = 6
Dim OutlApp As Object
Dim a(), x
Dim IsCreated As Boolean
' Use already open Outlook application if possible
'On Error Resume Next
Set OutlApp = GetObject(, "Outlook.Application")
If Err Then
Set OutlApp = CreateObject("Outlook.Application")
IsCreated = True
End If
CustName = Selection.Value
With OutlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
FoldName = CustName
.Folders.Add FoldName
End With
If IsCreated Then OutlApp.Quit
Set OutlApp = Nothing
End Sub