Post a message into a Public Folder

  • Thread starter Thread starter Dave
  • Start date Start date
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
 
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.
 
Back
Top