Re: Envoie de mails

Posté par R&B le 25/6/2004 14:01:10
Pas anglophone l'ami GoZeub on dirait
le troisième lien dans la page citée précédemment donne le code VB suivant.
Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
          Dim objOutlook As Outlook.Application
          Dim objOutlookMsg As Outlook.MailItem
          Dim objOutlookRecip As Outlook.Recipient
          Dim objOutlookAttach As Outlook.Attachment

          ' Create the Outlook session.
          Set objOutlook = CreateObject("Outlook.Application")

          ' Create the message.
          Set objOutlookMsg  = objOutlook.CreateItem(olMailItem)

          With objOutlookMsg
              ' Add the To recipient(s) to the message.
              Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
              objOutlookRecip.Type = olTo

              ' Add the CC recipient(s) to the message.
              Set objOutlookRecip = .Recipients.Add("Michael Suyama")
              objOutlookRecip.Type = olCC

             ' Add the BCC recipient(s) to the message.
              Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
              objOutlookRecip.Type = olBCC

             ' Set the Subject, Body, and Importance of the message.
             .Subject = "This is an Automation test with Microsoft Outlook"
             .Body = "This is the body of the message." &vbCrLf & vbCrLf
             .Importance = olImportanceHigh  'High importance

             ' Add attachments to the message.
             If Not IsMissing(AttachmentPath) Then
                 Set objOutlookAttach = .Attachments.Add(AttachmentPath)
             End If

             ' Resolve each Recipient's name.
             For Each ObjOutlookRecip In .Recipients
                 objOutlookRecip.Resolve
             Next

             ' Should we display the message before sending?
             If DisplayMsg Then
                 .Display
             Else
                 .Save
                 .Send
             End If
          End With
          Set objOutlook = Nothing
      End Sub


Une recherche attentive sur fcdaw semble indiquer qu'outlook réagit mal à ce genre de procédé. En effet, il semble demander confirmation de l'envois d'un mail réalisé à partir d'une autre application. Et cela semble limiter la capacité d'envois à 1 toute les 10 secondes !

Autre lien en français dans le texte.

Cette contribution était de : http://old.wdforge.org/newbb/viewtopic.php?forum=12&topic_id=1010&post_id=4388