
Je souhaiterais verifier qu'un message est bien envoyé dans Outlook 2016
il me semble que la meilleure solution est de vérifier que celui ci se trouve bien dans le dossier éléments envoyés
( A priori je ne connais pas d'autre solution

J'ai trouvé quelques informations sur internet mais je coince sur la manière de lister ce qui se trouve dans le dossier
éléments envoyés.... ci dessous les informations tréouvées sur internet ...
En vous remerciant pour votre aide et vos conseils

Jean-Marc
Code : Tout sélectionner
$olFolderInbox = 6
$ol = new-object -comobject "Outlook.Application"
$namespace = $ol.getnamespace("mapi")
#$mapi.Accounts
#$mapi.AddressLists
#$mapi.Folders
#$mapi.Application
#$mapi.AutoDiscoverConnectionMode
#$mapi.AutoDiscoverXml
#$mapi.AutoDiscoverConnectionMode
#$mapi.Parent
#$mapi.folders
#$mapi.Categories
#$mapi.folders
#$mapi.Parent
#$mapi.ExchangeConnectionMode
#$mapi.ExchangeMailboxServerName
#$mapi.ExchangeMailboxServerVersion
#$mapi.GetDefaultFolder(olFolderSentMail)
#olFolderSentMail
#olFolderDeletedItems
#olFolderOutbox
#olFolderSentMail
#olFolderInbox
#olFolderCalendar
#olFolderContacts
#olFolderJournal
#olFolderNotes
#olFolderTasks
#olFolderDrafts
#olPublicFoldersAllPublicFolders
#olFolderConflicts
#olFolderSyncIssues
#olFolderLocalFailures
#olFolderServerFailures
#olFolderJunk
#olFolderRssFeeds
#olFolderToDo
#olFolderManagedEmail
#olFolderSuggestedContacts
$inbox = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$emails = $inbox.Items | Where-Object {$_.Subject -like $subjectComparisonExpression}
#The $emails variable will contain a list of just those emails that were sent from SSRS. Now, for each of those, we can apply some processing. For instance:
# Process the reports by recipient
ForEach ($email in $emails)
{
# Look at all the attachments in a single email
ForEach ($attach in $email.Attachments)
{
# Not the most robust way to do it, but extract only the first pdf.. there shouldn't be more than one anyway
if ($attach.filename.contains("pdf"))
{
# Set the customer filename and paths and save off their report
# Save the main file
# Prepare outgoing emails (see following article section)
} } }
$template = get-childitem $emailTemplatePath -Filter "$emailTemplatePattern$customer.oft"
if ((Test-Path $template.FullName) -eq $true) # Make sure there's a template to use
{
# Create the email from a template
$emailToCustomer = $outlook.CreateItemFromTemplate($template.FullName.ToString())
# Expand the contact groups
# Start with the To line
$toListOriginal = $emailToCustomer.To
$toListNew = $null
$contacts = $namespace.GetDefaultFolder($olFolderContacts).Items # All the contacts in outlook
foreach ($to in $toListOriginal) # Enumerate the list of To's
{
$toContacts = $contacts.Item($to)
for ($i = 1; $i -le $toContacts.MemberCount; $i++)
{
$toContact = $toContacts.GetMember($i)
[array]$toListNew = $toListNew + $toContact
}
}
# Expand the CC line
$ccListOriginal = $emailToCustomer.CC
$ccListNew = $null
$contacts = $namespace.GetDefaultFolder($olFolderContacts).Items # All the contacts in outlook
foreach ($cc in $ccListOriginal) # Enumerate the list of CC's
{
$ccContacts = $contacts.Item($cc)
for ($i = 1; $i -le $ccContacts.MemberCount; $i++)
{
$ccContact = $ccContacts.GetMember($i)
[array]$ccListNew = $ccListNew + $ccContact
}
}
# Convert to string
if ([string]::IsNullOrEmpty($toListNew) -eq $false)
{
$toListFinal = $null
foreach ($to in $toListNew) { $toListFinal = $toListFinal + $to.Address + ";" }
$toListFinal = $toListFinal.Substring(0, $toListFinal.Length - 1) # Trim final ;
$emailToCustomer.To = $toListFinal
}
if ([string]::IsNullOrEmpty($ccListNew) -eq $false)
{
$ccListFinal = $null
foreach ($cc in $ccListNew) { $ccListFinal = $ccListFinal + $cc.Address + ";" }
$ccListFinal = $ccListFinal.Substring(0, $ccListFinal.Length - 1) # Trim final ;
$emailToCustomer.CC = $ccListFinal
}
# Customize the rest of the message as needed
$emailToCustomer.Attachments.Add($fileFullPath) | Out-Null
$emailToCustomer.HTMLBody = $emailToCustomer.HTMLBody.Replace("[Month]", $priorMonth)
$emailToCustomer.HTMLBody = $emailToCustomer.HTMLBody.Replace("[Year]", $priorYear)
$emailToCustomer.Save()
}
Si vous ne savez pas comment mettre en forme votre message et utiliser les balises de code, veuillez consulter ce lien : http://www.autoitscript.fr/forum/viewto ... f=35&t=595