Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Access > VBA Access
VBA Access Le forum pour les questions relatives au code VBA sous Access, et à son environnement de développement VBE.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 13/10/2011, 13h42   #1
Invité régulier
 
Homme
Technicien informatique
Inscription : mai 2011
Messages : 29
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Suisse

Informations professionnelles :
Activité : Technicien informatique
Secteur : Industrie Pharmaceutique

Informations forums :
Inscription : mai 2011
Messages : 29
Points : 5
Points : 5
Par défaut pièces attachées envoi de mail

Bonjour,

Dans une application j'ai un bouton qui envoi un mail avec une pièce attachée.

cela fonctionne très bien (C'est un code que j'ai trouvé sur un forum)

Code :
Call oh_SendMail("mon_email@gmail.com", "UPDATE", "Tout est en ordre" & vbCrLf & "avec ce mail", "C:\chemin\fichier.pdf"
J'aimerais attaché une deuxième pièces je ne trouve pas la syntaxe. J'ai essayé ceci mais j'obtiens une erreur

Code :
Call oh_SendMail("mon_email@gmail.com", "UPDATE", "Tout est en ordre" & vbCrLf & "avec ce mail", "C:\chemin\fichier.pdf" & " " & "C:\chemin\fichier2.pdf"
Message d'erreur:

La syntaxe du nom de fichier, de répertoire ou de volume est incorrect


Merci
pasb71 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/10/2011, 14h28   #2
Expert Confirmé
 
Avatar de Godzestla
 
Homme
Chercheur de bonheur
Inscription : août 2007
Messages : 2 256
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 47
Localisation : Belgique

Informations professionnelles :
Activité : Chercheur de bonheur
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 2 256
Points : 2 979
Points : 2 979
Bonjour,

c'est évident que cela ne peut fonctionner sans adapter la procédure
qui vraisemblablement est prévue pour 1 seul attachement.

D'une manière générale, changer la nature d'un paramêtre à l'appel sans adapter la procédure appelée conduit à 1 seule chose :
__________________
(\ _ /) Cordialement G@dz
(='.'=)

(")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.
Godzestla est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/10/2011, 14h33   #3
Invité régulier
 
Homme
Technicien informatique
Inscription : mai 2011
Messages : 29
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Suisse

Informations professionnelles :
Activité : Technicien informatique
Secteur : Industrie Pharmaceutique

Informations forums :
Inscription : mai 2011
Messages : 29
Points : 5
Points : 5
merci,

voici la procédure que j'ai

Code :
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
Option Compare Database
 
 
 
 
 
Public Const MAIL_SENDUSING = 2
 
Public Const MAIL_AUTHENTICATE = 1
 
Public Const MAIL_CPT_SENDUSR = "mon email"
 
Public Const MAIL_CPT_SENDPASS = "mon mot de passe"
 
Public Const MAIL_FROM = "de quelle adresse"
 
Public Const MAIL_SMTP_SERVER = "mon serveur"
 
Public Const MAIL_SMTP_SERVERPORT = 587
 
Public Function oh_SendMail(strDestinataire As String, strSujetMail As String, strContenuMail As String, strattacheMail As String) As Boolean
 
 
 
 
On Error GoTo oh_SendMail_Err
 
Dim i As Long
 
 
 
Dim objEmail As New CDO.Message
 
 
'Qui est l’expéditeur du mail
objEmail.From = MAIL_CPT_SENDUSR
 
' Qui est le destinataire du mail
objEmail.To = strDestinataire
'Le sujet du mail
objEmail.Subject = strSujetMail
 
'Le corps du message
objEmail.TextBody = strContenuMail
 
objEmail.AddAttachment strattacheMail
 
' Les paramètres pour gérer l’authentification sur le serveur OpenHost
 
With objEmail.Configuration.Fields
 
.Item(CdoConfiguration.cdoSendUsingMethod) = MAIL_SENDUSING
 
.Item(CdoConfiguration.cdoSMTPAuthenticate) = MAIL_AUTHENTICATE
 
.Item(CdoConfiguration.cdoSendUserName) = MAIL_CPT_SENDUSR
 
.Item(CdoConfiguration.cdoSendPassword) = MAIL_CPT_SENDPASS
 
.Item(CdoConfiguration.cdoSMTPServer) = MAIL_SMTP_SERVER
 
.Item(CdoConfiguration.cdoSMTPServerPort) = MAIL_SMTP_SERVERPORT
 
.Update
 
End With
 
 
objEmail.send
 
oh_SendMail = True
 
Exit Function
 
oh_SendMail_Err:
 
MsgBox Err.Description
 
oh_SendMail = False
 
End Function
pasb71 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/10/2011, 14h45   #4
Expert Confirmé
 
Avatar de Godzestla
 
Homme
Chercheur de bonheur
Inscription : août 2007
Messages : 2 256
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 47
Localisation : Belgique

Informations professionnelles :
Activité : Chercheur de bonheur
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 2 256
Points : 2 979
Points : 2 979
Re,

tu confirmes donc mon impression.

Pour le reste, je ne connais pas CDO donc je ne saurais t'aider. Fais des recherche dans le forum. Je sais que Patrick Toulon a fait des guides sur le sujet. Ils doivent être dans Contribuer ou aussi via sa signature.

Bonne chance.
__________________
(\ _ /) Cordialement G@dz
(='.'=)

(")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.
Godzestla est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/10/2011, 15h31   #5
Invité régulier
 
Homme
Technicien informatique
Inscription : mai 2011
Messages : 29
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Suisse

Informations professionnelles :
Activité : Technicien informatique
Secteur : Industrie Pharmaceutique

Informations forums :
Inscription : mai 2011
Messages : 29
Points : 5
Points : 5
J'ai trouvé la solution,

voici

mon code:

Code :
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
Option Compare Database
 
 
 
 
 
Public Const MAIL_SENDUSING = 2
 
Public Const MAIL_AUTHENTICATE = 1
 
Public Const MAIL_CPT_SENDUSR = "mon email"
 
Public Const MAIL_CPT_SENDPASS = "mon mot de passe"
 
Public Const MAIL_FROM = "de quelle adresse"
 
Public Const MAIL_SMTP_SERVER = "mon serveur"
 
Public Const MAIL_SMTP_SERVERPORT = 587
 
Public Function oh_SendMail(strDestinataire As String, strSujetMail As String, strContenuMail As String, strattacheMail1 As String,, strattacheMail2 As String) As Boolean
 
 
 
 
On Error GoTo oh_SendMail_Err
 
Dim i As Long
 
 
 
Dim objEmail As New CDO.Message
 
 
'Qui est l’expéditeur du mail
objEmail.From = MAIL_CPT_SENDUSR
 
' Qui est le destinataire du mail
objEmail.To = strDestinataire
'Le sujet du mail
objEmail.Subject = strSujetMail
 
'Le corps du message
objEmail.TextBody = strContenuMail
 
objEmail.AddAttachment strattacheMail1
objEmail.AddAttachment strattacheMail2
 
' Les paramètres pour gérer l’authentification sur le serveur OpenHost
 
With objEmail.Configuration.Fields
 
.Item(CdoConfiguration.cdoSendUsingMethod) = MAIL_SENDUSING
 
.Item(CdoConfiguration.cdoSMTPAuthenticate) = MAIL_AUTHENTICATE
 
.Item(CdoConfiguration.cdoSendUserName) = MAIL_CPT_SENDUSR
 
.Item(CdoConfiguration.cdoSendPassword) = MAIL_CPT_SENDPASS
 
.Item(CdoConfiguration.cdoSMTPServer) = MAIL_SMTP_SERVER
 
.Item(CdoConfiguration.cdoSMTPServerPort) = MAIL_SMTP_SERVERPORT
 
.Update
 
End With
 
 
objEmail.send
 
oh_SendMail = True
 
Exit Function
 
oh_SendMail_Err:
 
MsgBox Err.Description
 
oh_SendMail = False
 
End Function

code de mon bouton:

Code :
Call oh_SendMail("mon_email@gmail.com", "UPDATE", "Tout est en ordre" & vbCrLf & "avec ce mail", "C:\chemin\fichier.pdf", "C:\chemin\fichier2.pdf"
pasb71 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/10/2011, 15h49   #6
Expert Confirmé
 
Avatar de Godzestla
 
Homme
Chercheur de bonheur
Inscription : août 2007
Messages : 2 256
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 47
Localisation : Belgique

Informations professionnelles :
Activité : Chercheur de bonheur
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 2 256
Points : 2 979
Points : 2 979
Chouette.
Pense au bouton
__________________
(\ _ /) Cordialement G@dz
(='.'=)

(")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.
Godzestla est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 05h02.


 
 
 
 
Partenaires

Hébergement Web