MS Outlook code stage doesnt work in BP

budziakkamil

New Member
Hey.

I need to save draft mail in specific folder in specific mailbox.

I got a code that is working fine from MS:O marco level(as expected)


Public Sub CreateMail()
Dim myNameSpace As Outlook.NameSpace
Dim MyEmail As MailItem
' Create a new Outlook message item programatically
Set MyEmail = Application.CreateItem(olMailItem)
'Set your new message to, subject, body text and cc fields.

Set oba = Application.Session.GetDefaultFolder(olFolderDrafts)


With MyEmail
.To = "recipient@myserver.com"
.Subject = oba
.Body = Now()
.CC = "cc@myserver.com"
.SentOnBehalfOfName = "MAILBOX@DOMAIN.COM"
End With
MyEmail.Display


Set objOutlook = Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objSourceFolder = objNamespace.GetDefaultFolder(olFolderDrafts)
Set objItem = objOutlook.ActiveInspector.CurrentItem
Set objDestFolder = objNamespace.Folders("MAILBOX").Folders("Drafts")

objItem.Move (objDestFolder)

End Sub

Attaching 2 screens:

first one: just after paste to Code Stage
second -> removed 'set' due to result of first code check.

Can someone help?
 

Attachments

  • pic 2.PNG
    pic 2.PNG
    99 KB · Views: 3
  • pic 1.PNG
    pic 1.PNG
    58.1 KB · Views: 3
Top