Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Outlook: save in a specific folder
I'm trying to automate Outlook to save messages in FolderDrafts.
I've found that with the following code NOT always messages as saved there,
but sometimes in Received emails, other times elsewhere.
m.loOutLook = CREATEOBJECT('Outlook.Application')
m.loOutLookItem = m.loOutLook.CreateItem(0)
m.loOutLookItem.TO = "To Send To"
m.loOutLookItem.Subject = "Here subject"
m.loOutLookItem.Body = "Here body"
m.loOutLookItem.Save()
So I tried to select the draft folder (or, to test, other folders) but got error in marked lines:
m.loOutLook = CREATEOBJECT('Outlook.Application')
m.loOutLookItem = m.loOutLook.CreateItem(0)
m.loOutLookItem.TO = "To Send To"
m.loOutLookItem.Subject = "Here subject"
m.loOutLookItem.Body = "Here body"
m.loNamespace = m.loOutLook.GetNamespace("MAPI")
*m.loFolder = m.loNamespace.GetDefaultFolder(16) && olFolderDrafts = 16
*to test
m.loFolder = m.loNamespace.GetDefaultFolder(5) && olFolderSentMail = 5
*m.loOutLook.ActiveExplorer.CurrentFolder = m.loFolder &&this gives error
*m.loOutLook.ActiveExplorer.SelectFolder(m.loFolder) &&this gives error too
*
m.loOutLookItem.Save() &&it's saved (usually in olFolderDrafts , but not always!?)
So my question is, which is the code to shurely select a specific folder where the Save() method stores the message?
TIA
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement