Reputation: 1
I wrote Excel VBA code to generate emails from a report that is downloaded into Excel. It saves to the "drafts" folder in Outlook.
I want to save to another folder within drafts to keep them separate from my regular drafts.
This is what I have.
With objMail
.To = rngTo
.Subject = "Next 2 Weeks Orders"
.HTMLBody = intro & vbNewLine & po & signiature
.Save
End With
Upvotes: 0
Views: 757
Reputation: 66296
What is your code that actually creates objMail
? Are you using Application.CreateItem
? Use MAPIFolder.Items.Add
on a specific folder instead. Assuming "My custom subfolder" is a child folder of the Drafts folder:
set folder = objOutlook.Session.GetDefaulFolder(16) 'olfolderDrafts
set folder = folder.Folders("My custom subfolder")
set objMail = folder.Items.Add
Upvotes: 0
Reputation: 49455
There are several ways to create new items in Outlook. If you need to save a new item to a specific folder in Outlook you choices are:
CreateItem
method and then use the MoveTo
method to place the item to the target folder.Items.Add
method which places new items to the folder where the Items
collection comes from. For example:nSpace = OutlookApp.GetNamespace("MAPI")
targetFolder = nSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
folderItems = targetFolder.Items
mail = folderItems.Add(Outlook.OlItemType.olMailItem)
You can find all these ways described with code samples in the How to create and show a new Outlook mail item programmatically: C#, VB.NET article.
Upvotes: 0