Bonjour,
J'utilise depuis longtemps une macro VBA sous Access 2003. Je viens tout juste de changer d'OS (de XP à Seven). Depuis ce changement l'envoie d'un Email avec une piece attachée est devenue impossible (il semblerai que le fichier que j'envoie en pièce jointe ne s'envoie plus).
Code du bouton:
Code de CreateEmail:
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 Private Sub Commande2_Click() Dim adressemail As String Dim bodyt As String dateEnvoie = Forms![EXPORTATION DONNEE RAPPORT VOYAGE]![Daterapport].Value AdresseFichier = "C:\rapport_du_" & dateEnvoie & ".xls" DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "EXPORTATION RAPPORT", AdresseFichier, True adressemail = Forms![EXPORTATION DONNEE RAPPORT]![destinataire].Value If IsNull(Forms![EXPORTATION DONNEE RAPPORT]![sujet].Value) Then sujet = "Rapport" Else sujet = Forms![EXPORTATION DONNEE RAPPORT]![sujet].Value End If If IsNull(Forms![EXPORTATION DONNEE RAPPORT]![bodyt].Value) Then bodyt = "Rapport" Else bodyt = Forms![EXPORTATION DONNEE RAPPORT]![bodyt].Value End If Call CreateEmail(adressemail, sujet, bodyt, AdresseFichier) DoEvents Kill AdresseFichier MsgBox ("Le mail est prêt. N'oubliez pas d'ouvrir outlook et cliquer sur 'Envoyer / Recevoir'") DoCmd.Close acForm, "EXPORTATION DONNEE RAPPORT", acSaveNo End Sub
Erreur:
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 Public Sub CreateEmail( _ Recipient As String, _ Subject As String, _ Body As String, _ Optional Attach As Variant) ' -------------------------- Dim I As Integer Dim oEmail As Outlook.MailItem Dim appOutLook As Outlook.Application ' créer un nouvel item mail Set appOutLook = New Outlook.Application Set oEmail = appOutLook.CreateItem(olMailItem) ' les paramètres oEmail.To = Recipient oEmail.Subject = Subject oEmail.Body = Body If Not IsMissing(Attach) Then If TypeName(Attach) = "String" Then ' s'il y a des pièces jointes oEmail.Attachments.Add Attach Else For I = 0 To UBound(Attach) - 1 oEmail.Attachments.Add Attach(I) Next End If End If ' envoie le message oEmail.Send ' détruit les références aux objets Set oEmail = Nothing Set appOutLook = Nothing End Sub
Dois-je changer quelque chose dans le code ou es-ce juste une configuration à l'intérieur de Windows Seven que je dois changer (empèche t'il par exemple la création d'un fichier par sécurité)?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 Erreur d'exécution '-1836646398 (92870002)': Impossible de trouver ce fichier. Vérifiez que le chemin d'accès et le nom du fichier sont corrects.
Merci
Partager