envoi mail en html avec tableau dans le corps du mail.

Le
sleg
BOnjour,

Voici mon probleme enfin 2 preblemes .
Probleme 1 :
je ne reçois pas le mail ???? et la je bloque et je n'ai aucun message
d'erreur

Probleme 2 :
je ne vois pas comment mettre un tableau dun feuille excel dans le
corps de mon mail

merci de votre aide.

j'utilise le code ci-dessous.

Sub sendmail2()
Dim Email As Outlook.MailItem
Dim strHTML As String
Dim Obj_Outlook As Outlook.Application
Dim New_Mail As Outlook.Items

' Création objet Application Outlook
Set Obj_Outlook = CreateObject("outlook.Application")
' Création objet Nouveau message
Set Email = Obj_Outlook.CreateItem(olMailItem)
Email.ReadReceiptRequested = False
Email.To = "toto@tata.fr"
Email.cc = ""
Email.BCC = ""
Email.Subject = "Dashboard Incidents " & Now()
Email.FlagIcon = olYellowFlagIcon
Email.Importance = olImportanceHigh
' Attachement de la pièce jointe
Set Attachment = Email.Attachments
Attachment.Add "ep1monfichier.xls", 1, 500, "Nom du fichier
joint "
' Première solution en format HTML
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<FONT face=Calibri (Corps) color=#110000
size=2>"
strHTML = strHTML & "Bonjour à tous,</br>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> texte 1."
strHTML = strHTML & "<br> texte2. (fichier Excel) "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> texte1 eng"
strHTML = strHTML & "<br> texte2 eng "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span style=background:#ffff00>SYNTHESE :</
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "


'inserer le tableau se trouvant dans onglet synthèse a5:d25


strHTML = strHTML & "<br>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br>"
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span style=background:#ffff00>TITRE 1:</
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "Ton texte ici."
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "


'inserer le tableau se trouvant dans onglet synthèse H5:I9


strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span style=background:#ffff00>TITRE 2 : </
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "Ton texte ici."
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span style=background:#ffff00>TITRE 3 : </
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "Ton texte ici."
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span style=background:#ffff00>AUTRES : </
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "Ton texte ici."
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "</FONT>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"
Email.HTMLBody = strHTML
' Affichage mail
'Email.Display
'Ou envoi du mail
Email.Send
End Sub
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
MichD
Le #23360541
Bonjour,

Un exemple d'une envoi de la feuille active en Html
dans un message par Microsoft Outlook
Je n'ai plus l'auteur de ces lignes :

'-------------------------------------
Sub MailActiveSheet()
Application.ScreenUpdating = False
With CreateObject("Outlook.Application")
With .CreateItem(0)
.To = ""
.Subject = "Test d'envoi de la feuille active !"
.HTMLBody = HTML(ActiveSheet)
.Send
End With
End With
End Sub
'-------------------------------------
Private Function HTML(sh As Worksheet) As String
On Error Resume Next
Const Tmp As String = "C:temp.htm"
Kill Tmp: sh.Copy: Dim Shp As Shape
For Each Shp In ActiveSheet.Shapes: Shp.Delete: Next
ActiveWorkbook.SaveAs Tmp, xlHtml
ActiveWorkbook.Close False
Dim fso As Object, ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Tmp, 1)
HTML = ts.ReadAll: ts.Close: Kill Tmp
Set ts = Nothing: Set fso = Nothing
End Function
'-------------------------------------


MichD
--------------------------------------------
"sleg" a écrit dans le message de groupe de discussion :


BOnjour,

Voici mon probleme enfin 2 preblemes .
Probleme 1 :
je ne reçois pas le mail ???? et la je bloque et je n'ai aucun message
d'erreur...

Probleme 2 :
je ne vois pas comment mettre un tableau dun feuille excel dans le
corps de mon mail

merci de votre aide.

j'utilise le code ci-dessous.

Sub sendmail2()
Dim Email As Outlook.MailItem
Dim strHTML As String
Dim Obj_Outlook As Outlook.Application
Dim New_Mail As Outlook.Items

' Création objet Application Outlook
Set Obj_Outlook = CreateObject("outlook.Application")
' Création objet Nouveau message
Set Email = Obj_Outlook.CreateItem(olMailItem)
Email.ReadReceiptRequested = False
Email.To = ""
Email.cc = ""
Email.BCC = ""
Email.Subject = "Dashboard Incidents " & Now()
Email.FlagIcon = olYellowFlagIcon
Email.Importance = olImportanceHigh
' Attachement de la pièce jointe
Set Attachment = Email.Attachments
Attachment.Add "\rep1monfichier.xls", 1, 500, "Nom du fichier
joint "
' Première solution en format HTML
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<FONT faceÊlibri (Corps) color=#110000
size=2>"
strHTML = strHTML & "Bonjour à tous,</br>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> texte 1."
strHTML = strHTML & "<br> texte2. (fichier Excel) "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> texte1 eng"
strHTML = strHTML & "<br> texte2 eng "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span styleºckground:#ffff00>SYNTHESE :</
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "


'inserer le tableau se trouvant dans onglet synthèse a5:d25


strHTML = strHTML & "<br>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br>"
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span styleºckground:#ffff00>TITRE 1:</
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "Ton texte ici."
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "


'inserer le tableau se trouvant dans onglet synthèse H5:I9


strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span styleºckground:#ffff00>TITRE 2 : </
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "Ton texte ici."
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span styleºckground:#ffff00>TITRE 3 : </
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "Ton texte ici."
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<b>"
strHTML = strHTML & "<span styleºckground:#ffff00>AUTRES : </
span>"
strHTML = strHTML & "</b>"
strHTML = strHTML & "<br> "
strHTML = strHTML & "Ton texte ici."
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "<br> "
strHTML = strHTML & "</FONT>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"
Email.HTMLBody = strHTML
' Affichage mail
'Email.Display
'Ou envoi du mail
Email.Send
End Sub
Publicité
Poster une réponse
Anonyme