[..] Lister messges envoyés OUtlook 2016

Aide et conseils concernant AutoIt et ses outils.
Règles du forum
.
Répondre
jcaspar
Niveau 7
Niveau 7
Messages : 449
Enregistré le : mar. 23 sept. 2008 17:58
Status : Hors ligne

[..] Lister messges envoyés OUtlook 2016

#1

Message par jcaspar »

B :D onjour à tous !

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 :?: ... mais si vous en avez une à me conseiller je suis preneur )

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 :mrgreen:

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
Avatar du membre
Nine
AutoIt MVPs (MVP)
AutoIt MVPs (MVP)
Messages : 103
Enregistré le : ven. 17 avr. 2020 01:23
Status : Hors ligne

Re: [..] Lister messges envoyés OUtlook 2016

#2

Message par Nine »

Il y a tout ce dont tu as besoin dans le UDF de water : https://www.autoitscript.com/forum/file ... outlookex/

Un exemple :

Code : Tout sélectionner

#include <Constants.au3>
#include "OutlookEX 1.6.2.0\OutlookEX.au3"

Opt ("MustDeclareVars", 1)

Global $oOutlook = _OL_Open(True,@ScriptDir & "\OutlookEX 1.6.2.0\_OL_Warnings.exe",10)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error)

Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderSentMail)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing folder. @error = " & @error)
$aFolder[1].Display

; https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem
; for a list of all item properties
Global $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "", "", "", "EntryID,SenderName,Subject,To,CreationTime","", 1)

Global $oItem = _OL_ItemGet($oOutlook, $aItems[1][0], Default, -1)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing properties. @error = " & @error)

If IsArray($aItems) Then
  _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind Example Script")
Else
  MsgBox(48, "OutlookEX UDF", "Could not find an unread mail. @error = " & @error)
EndIf
_OL_Close($oOutlook)
jcaspar
Niveau 7
Niveau 7
Messages : 449
Enregistré le : mar. 23 sept. 2008 17:58
Status : Hors ligne

Re: [..] Lister messges envoyés OUtlook 2016

#3

Message par jcaspar »

Merci beaucoup pour votre réponse !

Je coince avec l'utilisation de l'UDF savez vous si il existe un tutoriel pour paramétrer l'utilisation d'include avec scite ?

si j'ai bien compris il faut paramétrer la configuration de Scite dans le fichier de configuration ... mais j'ignore quelle ligne modifier

En copiant collant les fichiers dans le dossier include ou le dossier complet ...

Peut être existe il un tutoriel en ligne ou sur le site ?

En vous remerciant pour vos conseils
Avatar du membre
Nine
AutoIt MVPs (MVP)
AutoIt MVPs (MVP)
Messages : 103
Enregistré le : ven. 17 avr. 2020 01:23
Status : Hors ligne

Re: [..] Lister messges envoyés OUtlook 2016

#4

Message par Nine »

Avec l'UDF, vient un ensemble d'exemples (au3) et d'explications (html).
Il n'y a rien à changer dans Scite.
Il faut mettre (extraire) tous les fichiers dans un sous-répertoire, puis #include le fichier UDF maître "OutlookEX.au3" dans notre script (voir mon exemple).

Il existe un Wiki :

https://www.autoitscript.com/wiki/Outlo ... _-_General
Répondre