OVH Cloud OVH Cloud

envoyer e-mail de excel

2 réponses
Avatar
Eric T.
Bonjour,

comment faire pour combiner les deux macro ?=20

macro 1 (sert =E0 envoyer un nouveau e-mail =E0 partir d'excel)

Dim ol As New Outlook.Application
Dim olmail As MailItem
Set ol =3D New Outlook.Application
Set olmail =3D ol.CreateItem(olMailItem)
With olmail
.To =3D Range("a3").Value
.Subject =3D Range("a6").Value
.Display
.Body =3D Range("c5").Value
.Send
End With
End sub=20

Macro 2 (sert =E0 s=E9lectionner le fichier excel et le joint=20
dans outlook)

Application.Dialogs(xlDialogSendMail).Show

End sub


Merci !

Eric

2 réponses

Avatar
papou
Bonjour Eric
Comme ceci :
(Attention, aucun test n'est effectué sur la valeur de ThisWorkbook.Name)
Dim ol As New Outlook.Application
Dim olmail As MailItem
Set ol = New Outlook.Application
Set olmail = ol.CreateItem(olMailItem)
With olmail
.To = Range("a3").Value
.Subject = Range("a6").Value
.Display
.Body = Range("c5").Value
.Attachments.Add (ThisWorkbook.FullName)
.Send
End With
Set olmail = Nothing
Set ol = Nothing

Cordialement
Pascal

"Eric T." a écrit dans le message de
news:1ffd01c3e05d$e6ec1dc0$
Bonjour,

comment faire pour combiner les deux macro ?

macro 1 (sert à envoyer un nouveau e-mail à partir d'excel)

Dim ol As New Outlook.Application
Dim olmail As MailItem
Set ol = New Outlook.Application
Set olmail = ol.CreateItem(olMailItem)
With olmail
.To = Range("a3").Value
.Subject = Range("a6").Value
.Display
.Body = Range("c5").Value
.Send
End With
End sub

Macro 2 (sert à sélectionner le fichier excel et le joint
dans outlook)

Application.Dialogs(xlDialogSendMail).Show

End sub


Merci !

Eric
Avatar
papou
Heu...
(Attention, aucun test n'est effectué sur la valeur de ThisWorkbook.Name)
ThisWorkbook.FullName

Pardon

Cordialement
Pascal

"papou" <nspm> a écrit dans le message de
news:
Bonjour Eric
Comme ceci :
(Attention, aucun test n'est effectué sur la valeur de ThisWorkbook.Name)
Dim ol As New Outlook.Application
Dim olmail As MailItem
Set ol = New Outlook.Application
Set olmail = ol.CreateItem(olMailItem)
With olmail
.To = Range("a3").Value
.Subject = Range("a6").Value
.Display
.Body = Range("c5").Value
.Attachments.Add (ThisWorkbook.FullName)
.Send
End With
Set olmail = Nothing
Set ol = Nothing

Cordialement
Pascal

"Eric T." a écrit dans le message de
news:1ffd01c3e05d$e6ec1dc0$
Bonjour,

comment faire pour combiner les deux macro ?

macro 1 (sert à envoyer un nouveau e-mail à partir d'excel)

Dim ol As New Outlook.Application
Dim olmail As MailItem
Set ol = New Outlook.Application
Set olmail = ol.CreateItem(olMailItem)
With olmail
.To = Range("a3").Value
.Subject = Range("a6").Value
.Display
.Body = Range("c5").Value
.Send
End With
End sub

Macro 2 (sert à sélectionner le fichier excel et le joint
dans outlook)

Application.Dialogs(xlDialogSendMail).Show

End sub


Merci !

Eric