Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

pb macro outlook

2 réponses
Avatar
julien Touche
Bonjour

est-ce que quelqu'un pourrait m'aider à trouver le pb dans cette macro ?

===
Sub test()
Dim objItem, toBodyTag, strFinalBody
Dim olMail As Outlook.MailItem
On Error Resume Next

Set objItem = Application.ActiveInspector.CurrentItem

' convert mail to html format
strID = objItem.EntryID
Set olNS = Application.GetNamespace("MAPI")
olMail = olNS.GetItemFromID(strID)
olMail.Save

olMail.BodyFormat = olFormatHTML

' replace
objItem.HTMLBody = Regex.Replace(objItem.HTMLBody, "^+ (.*)", "<b>+
$&</b>")
objItem.HTMLBody = Regex.Replace(objItem.HTMLBody, "^+ ([A-Z ].*)",
"<hr><br /><b>+ $&</b>")

Set theMail = Nothing
Set olNS = Nothing
Set objItem = Nothing
End Sub
===

à l'execution, rien ne se passe
- pas de changement de format texte en html
- pas de modification du body suivant les regex indiquées


merci
Cordialement

2 réponses

Avatar
Grég
Bonjour/soir,

Ci-dessous quelques modifs pour les erreurs de non déclaration de variables
et de "l'initialisation" à nothing d'un objet non existant.

En OL2K3 Regex, il ne connait pas!

Cordialement.
--->
Sub test()
Dim objItem, toBodyTag, strFinalBody, strID, olNS
Dim olMail As Outlook.MailItem
On Error Resume Next

Set objItem = Application.ActiveInspector.CurrentItem

' convert mail to html format
strID = objItem.EntryID
Set olNS = Application.GetNamespace("MAPI")
olMail = olNS.GetItemFromID(strID)
olMail.Save

olMail.BodyFormat = olFormatHTML

' replace
objItem.HTMLBody = Regex.Replace(objItem.HTMLBody, "^+ (.*)",
"<b>+$&</b>")
objItem.HTMLBody = Regex.Replace(objItem.HTMLBody, "^+ ([A-Z ].*)",
"<hr><br /><b>+ $&</b>")

Set olMail = Nothing
Set olNS = Nothing
Set objItem = Nothing
End Sub
<----
--
Grég
"julien Touche" a écrit dans le message de
news: 45eaa50f$0$32299$

Bonjour

est-ce que quelqu'un pourrait m'aider à trouver le pb dans cette macro ?

== > Sub test()
Dim objItem, toBodyTag, strFinalBody
Dim olMail As Outlook.MailItem
On Error Resume Next

Set objItem = Application.ActiveInspector.CurrentItem

' convert mail to html format
strID = objItem.EntryID
Set olNS = Application.GetNamespace("MAPI")
olMail = olNS.GetItemFromID(strID)
olMail.Save

olMail.BodyFormat = olFormatHTML

' replace
objItem.HTMLBody = Regex.Replace(objItem.HTMLBody, "^+ (.*)", "<b>+
$&</b>")
objItem.HTMLBody = Regex.Replace(objItem.HTMLBody, "^+ ([A-Z ].*)",
"<hr><br /><b>+ $&</b>")

Set theMail = Nothing
Set olNS = Nothing
Set objItem = Nothing
End Sub
== >
à l'execution, rien ne se passe
- pas de changement de format texte en html
- pas de modification du body suivant les regex indiquées


merci
Cordialement


Avatar
Geo

Évitez ceci :

On Error Resume Next


A vous aidera à comprendre ce qui se passe dans votre macro.

--
A+