Post a message into a Public Folder

D

Dave

I am trying to write code to post a message into a public
folder. When I run the code I have written nothing
posts. Would greatly appreciate any suggestions to
correct the code I have written.

Sub AttachSalesFile()
Dim objOutlook As Outlook.Application
Dim objOutlookPst As Outlook.PostItem
Dim objNS As Outlook.NameSpace
Dim objFolder As MAPIFolder

Dim objOutlookAttach As Outlook.Attachment

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookPst = objOutlook.CreateItem(olPostItem)
Set objNS = objOutlook.GetNamespace("MAPI")

Set objFolder = objNS.Folders.Item("Public
Folders").Folders.Item("All Public Folders"). _
Folders.Item("Pottery Barn").Folders.Item("PB
Brand Finance")
Set objFolder = objNS.PickFolder


With objOutlookPst

.Subject = "JDA file for " & Date
' .Attachments.Add ("c:\MDCFiles\jda_cube.mdc")
.Post
End With
Set objOutlookPst = Nothing
Set objOutlook = Nothing
Set objNS = Nothing
Set objFolder = Nothing
End Sub
 
K

Ken Slovak - [MVP - Outlook]

Use the Add method for the Items collection of that folder instead of
CreateItem or after you have saved the item using your method use the Move
function to move it to the folder you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top