Mise en forme Macro + ajout auto signature

Good morning le forum,

Afin de terminer l´automatisation d´un travail, il me manque deux étàpes:

1- Ajouter autamtiquement ma signature lors de la creation du mail automatique

2- Mettre en forme le corps du mail.

Le code de mon body est:

Attachments.Add destwb.FullName
                .body = "Buenos días " & Workbooks("Exemple").Sheets("OGNLET 2").Range("b8").Value & vbLf & vbLf
        .body = .body & "Adjunto te envío los resultados de MFC de " & Workbooks("Exemple").Sheets("OGNLET 2").Range("b7").Value & " del mes de " & Workbooks("Exemple").Sheets("OGNLET 2").Range("b5").Value & "." & vbLf & vbLf
        .body = .body & "Este més ha impactado " & Workbooks("Exemple").Sheets("OGNLET 2").Range("b12").Value & " clientes reales, ganando " & Workbooks("Exemple").Sheets("OGNLET 2").Range("b13").Value & " por lo que el ratio de conversión es del " & Workbooks("Exemple").Sheets("OGNLET 2").Range("b14").Value & Workbooks("Exemple").Sheets("OGNLET 2").Range("b15").Value
        .body = .body & vbLf & "Hay " & Workbooks("Exemple").Sheets("OGNLET 2").Range("b16").Value & " campañas con buenos resultados:" & vbLf & vbLf
        .body = .body & "-" & Workbooks("Exemple").Sheets("OGNLET 2").Range("b17").Value & " con un ratio de " & Workbooks("Exemple").Sheets("OGNLET 2").Range("c17").Value & vbLf
        .body = .body & "-" & Workbooks("Exemple").Sheets("OGNLET 2").Range("b18").Value & " con un ratio de " & Workbooks("Exemple").Sheets("OGNLET 2").Range("c18").Value & vbLf
        .body = .body & "-" & Workbooks("Exemple").Sheets("OGNLET 2").Range("b19").Value & " con un ratio de " & Workbooks("Exemple").Sheets("OGNLET 2").Range("c19").Value & vbLf
        .body = .body & "-" & Workbooks("Exemple").Sheets("OGNLET 2").Range("b20").Value & " con un ratio de " & Workbooks("Exemple").Sheets("OGNLET 2").Range("c20").Value & vbLf
        .body = .body & "-" & Workbooks("Exemple").Sheets("OGNLET 2").Range("b21").Value & " con un ratio de " & Workbooks("Exemple").Sheets("OGNLET 2").Range("c21").Value & vbLf
        .body = .body & "-" & Workbooks("Exemple").Sheets("OGNLET 2").Range("b22").Value & " con un ratio de " & Workbooks("Exemple").Sheets("OGNLET 2").Range("c22").Value & vbLf
        .body = .body & vbLf & "Un cordíal saludo, "

Merci pour votre aide

Hello, si la mise en forme est importante et pour apposer ta signature automatiquement je te conseille de partir d'un template de mail oft

Bonjour,

C´est quoi oft ? :$

Merci

C'est un template de mail. (cf fichier joint pour exemple)

Tu crées tout ton corps de texte fixe et tu insères des parties variables que tu vas rechercher remplacer en fonction de ton tableau excel.

Tu remarqueras en ouvrant le fichier oft que c'est ta signature qui s'affiche.

61exemple-email.zip (11.85 Ko)

Salut,

Je ne vois pas trop comment l integrer à ma macro?

En gros tu me dis de ouvrir mon template mail, et de copier coler le corps de mon message via mon tableau Excel?

Un exemple ci-joint pour ouvrir un fichier oft et faire du rechercher remplacer:

Set OutApp = New Outlook.Application
Set OutMsg = OutApp.CreateItemFromTemplate("C:\XXXXXX\MAIL.oft")

OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "variableàremplacer", variablederemplacement)

Dans ton mail template tu vas placer ton texte fixe et des parties variables bien identifiées (moi je mets un texte entre pourcentages pour être sûr de bien remplacer le bon texte). Ensuite tu sauvegardes ton mail sans la signature au format oft.


Voici un oft exemple avec ton texte (dans le zip en attachement) et tes variables et le code VBA qui va avec.

Sub remplacement_outlook

Set OutApp = New Outlook.Application
Set OutMsg = OutApp.CreateItemFromTemplate("C:\XXXXXX\MAIL_exemple.oft")

OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B8%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b8").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B7%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b7").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B5%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b5").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B12%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b12").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B13%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b13").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B14%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b14").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B15%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b15").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B16%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b16").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B17%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b17").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B18%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b18").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B19%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b19").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B20%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b20").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B21%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b21").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%B22%", Workbooks("Exemple").Sheets("OGNLET 2").Range("b22").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%C17%", Workbooks("Exemple").Sheets("OGNLET 2").Range("c17").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%C18%", Workbooks("Exemple").Sheets("OGNLET 2").Range("c18").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%C19%", Workbooks("Exemple").Sheets("OGNLET 2").Range("c19").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%C20%", Workbooks("Exemple").Sheets("OGNLET 2").Range("c20").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%C21%", Workbooks("Exemple").Sheets("OGNLET 2").Range("c21").Value)
OutMsg.HTMLBody = Replace(OutMsg.HTMLBody, "%C22%", Workbooks("Exemple").Sheets("OGNLET 2").Range("c22").Value)

OutMsg.Display
End Sub
39mail-exemple.zip (14.26 Ko)

Super merci, je vais regarder tout caet je reviens vers toi (:

Rechercher des sujets similaires à "mise forme macro ajout auto signature"