P
ptisinge
Guest
bonjour je cherche a copier une serie de données dans une feuille et la copier dans le corps du message.
avec le code ci dessous j'arrive a envoyer un mail avec une piece jointe mai je voudrai mettre dans le corps du mail une serie de données qui sont dans sheets("Sheet1").range("F6:h26")
merci pour votre aide
Private Sub envoi_mail()
Dim Session As Object
Dim db As Object
Dim doc As Object
Dim rtitem As Object
Dim object As Object
Dim nom As String
Dim myTableau As String
nom = ActiveWorkbook.FullName
On Error GoTo TraiteErreur
' Ouverture d'une session NOTES
Set Session = CreateObject("Notes.NotesSession")
Set db = Session.GetDatabase("", "")
Call db.OPENMAIL
' Création du mail
Set doc = db.CreateDocument()
doc.Form = "Memo"
doc.SendTo = "xxx@yyyyy.com"
doc.Subject = "Petit test"
doc.From = Session.CommonUserName
'piece jointe
Set rtitem = doc.CreateRichTextItem("body2")
Call rtitem.AppendText("Veuillez trouver ci-joint le fichier ")
Set object = rtitem.EmbedObject(1454, "", nom, "")
' Envoi du mail
Call doc.Save(True, True)
Call doc.Send(False)
Set object = Nothing
Set rtitem = Nothing
Set doc = Nothing
Set db = Nothing
Set Session = Nothing
Exit Sub
TraiteErreur:
MsgBox "Une erreur est survenue durant l'envoi.", vbCritical, "Passage en Urgence"
Set object = Nothing
Set rtitem = Nothing
Set doc = Nothing
Set db = Nothing
Set Session = Nothing
Set fs = Nothing
End Sub
avec le code ci dessous j'arrive a envoyer un mail avec une piece jointe mai je voudrai mettre dans le corps du mail une serie de données qui sont dans sheets("Sheet1").range("F6:h26")
merci pour votre aide
Private Sub envoi_mail()
Dim Session As Object
Dim db As Object
Dim doc As Object
Dim rtitem As Object
Dim object As Object
Dim nom As String
Dim myTableau As String
nom = ActiveWorkbook.FullName
On Error GoTo TraiteErreur
' Ouverture d'une session NOTES
Set Session = CreateObject("Notes.NotesSession")
Set db = Session.GetDatabase("", "")
Call db.OPENMAIL
' Création du mail
Set doc = db.CreateDocument()
doc.Form = "Memo"
doc.SendTo = "xxx@yyyyy.com"
doc.Subject = "Petit test"
doc.From = Session.CommonUserName
'piece jointe
Set rtitem = doc.CreateRichTextItem("body2")
Call rtitem.AppendText("Veuillez trouver ci-joint le fichier ")
Set object = rtitem.EmbedObject(1454, "", nom, "")
' Envoi du mail
Call doc.Save(True, True)
Call doc.Send(False)
Set object = Nothing
Set rtitem = Nothing
Set doc = Nothing
Set db = Nothing
Set Session = Nothing
Exit Sub
TraiteErreur:
MsgBox "Une erreur est survenue durant l'envoi.", vbCritical, "Passage en Urgence"
Set object = Nothing
Set rtitem = Nothing
Set doc = Nothing
Set db = Nothing
Set Session = Nothing
Set fs = Nothing
End Sub
Dernière modification par un modérateur: