Bonsoir à tous,

Je viens vers vous car j'ai un soucis au niveau d'un codage que je suis entrai de réaliser.

Mon but est d'envoyer un mail automatiquement selon une liste. Le problème vient de l'envoi du mail :

- Comment définir la boite mail d'envoi ?
- Comment mettre un accusé de réception ?
- Comment mettre à la fois un corps de texte dans le mail et à la fois une pièce jointe.

Merci d'avance pour votre aide.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Dim Session As Object
    Dim db As Object
    Dim doc As Object
    Dim rtitem As Object
    Dim object As Object
    Dim fs As Object
    Dim Principaux(2) As String
    Dim Copies(3) As String
    Dim dir As Object
    Dim inti As Integer
    Dim passwd As String
 
    On Error GoTo TraiteErreur
 
    ' Création de la session Notes
    Set Session = CreateObject("Lotus.NOTESSESSION")
 
    'Ouverture d'une session NOTES
    Call Session.Initialize(passwd) 'si pas de passwd pas de parametre pour initialize
    Set dir = Session.GETDBDIRECTORY("FranceServer1/DCI/BME/Omnia Group")
    Set db = dir.OpenMailDatabase
 
    ' Création d'un document
    Set doc = db.CREATEDOCUMENT
    'affectation du type mail
    Call doc.APPENDITEMVALUE("Form", "Memo")
    Call doc.APPENDITEMVALUE("Sendto", "prenom.nom@societe.fr")
    Call doc.APPENDITEMVALUE("subject", "0" & Centre & " : Annonce PRO.")
    'Call doc.APPENDITEMVALUE("Body", "Bonjour,") ' & vbCrLf & "Afin d'améliorer ... texte " & vbCrLf & " Vous trouverez ci joint un fichier." & vbCrLf & vbCrLf & vbCrLf & " Merci de leur recevoir& vbCrLf & "Veuillez agréer l'expression de nos sentiments distingués." & vbCrLf & "La societe.")
    'doc.SAVEMESSAGEONSEND = saveit 'sauvegarde du mail à l envoi
 
    Set rtitem = doc.createRichTextItem("Body")
 
 
    Dim nom As String
    nom = ThisWorkbook.FullName
    'Attachement du classeur au mail
    Set object = rtitem.embedObject(1454, "", nom, "")
 
 
    Call doc.Send(True)
    Set object = Nothing
    Set rtitem = Nothing
    Set doc = Nothing
    Set db = Nothing
    Set Session = Nothing
    Exit Sub
TraiteErreur:
    MsgBox "Erreur Critique durant l envoi .", vbCritical, "Error"
    Set object = Nothing
    Set rtitem = Nothing
    Set doc = Nothing
    Set db = Nothing
    Set Session = Nothing
    Set fs = Nothing