Insérer des balises html dans du vbscript

piertomjack Messages postés 4 Date d'inscription vendredi 18 avril 2008 Statut Membre Dernière intervention 21 avril 2008 - 18 avril 2008 à 14:05
piertomjack Messages postés 4 Date d'inscription vendredi 18 avril 2008 Statut Membre Dernière intervention 21 avril 2008 - 21 avril 2008 à 16:13
bonjour,


j'aimerais savoir s'il est possible d'insérer du html avec vbs? en fait je réaliser un script de signature automatique (pour une entreprise)(on donne à chaque utilisateur un pc, et on lance le script pour générer la signature), et pour l'instant, j'ai réussi à récupérer les données, à créer un fichier htm et afficher les données avec le minimum de mise en page ( police + taille de caractères + image). Cependant le résultat est très loin de celui voulu car j'aimerais pouvoir décaler mon texte sur la droite, une sorte de mise en boite en quelque sorte...

5 réponses

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
19 avril 2008 à 12:14
salut,

euh, et quel est le problème?
tu as juste à encadrer ton texte actuel par
...
ou un truc du genre....

au cas où, la concaténation se fait par &

@+
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
0
piertomjack Messages postés 4 Date d'inscription vendredi 18 avril 2008 Statut Membre Dernière intervention 21 avril 2008
19 avril 2008 à 19:33
le problème, c'est que ça m'affiche le code html dans la signature, ça ne l'interprète pas... la ou j'aimerais afficher un texte sur la droite comme dans ton exemple : ça m'affiche :

Email:

j'ai réussi en faisant deux tableaux à améliorer la chose, mais il n'y a rien a faire, si je pouvais faire ça avec du html, ce serait mieux....
0
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
19 avril 2008 à 19:50
quel est ton code?

<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
0
piertomjack Messages postés 4 Date d'inscription vendredi 18 avril 2008 Statut Membre Dernière intervention 21 avril 2008
21 avril 2008 à 09:23
désolé du temps de réponse...
voici mon code, je précise qu'ici j'ai essayé de faire deux colonnes pour mettre en forme :




On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")



strUser = objSysInfo.UserName



Set objUser = GetObject("LDAP://" & strUser)





strName = objUser.FullName
strFirstName = objuser.givenName
StrLastName = objuser.sn
strTitle = objUser.Title
strDepartment = objUser.Department
strCompany = objUser.Company
strAddress = objuser.streetAddress
strCity = objuser.l
strState = objuser.st
strZip = objuser.postalCode
strPhone = objUser.telephoneNumber
strMobilePhone = objUser.mobile
strMail = objuser.mail
strWeb = objuser.wWWHomePage
strFax = objUser.faxNumber





Set objWord = CreateObject("Word.Application")
objWord.Visible = true



Set objDoc = objWord.Documents.Add()
objSelection.TypeText "______________________"
objSelection.TypeParagraph()
Set objDoc = objWord.Documents.Add()


Set objRange = objDoc.Range()
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries



objSelection.Font.Size = "8"
objSelection.Font.Name = "verdana"





objDoc.Tables.Add objRange, 1, 2
Set objTable = objDoc.Tables(1)



objSelection.TypeText "___________________"
objSelection.TypeParagraph()
objTable.Cell(1, 1).Range.Text = objSelection.InlineShapes.AddPicture("E:\untitled123.bmp")



objTable.Columns(1).Width = objWord.InchesToPoints(1)



objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeText ""
objSelection.TypeText "______________________________"
objTable.Cell(1, 2).Select
objSelection.TypeText "______________________________"
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText strFirstName & " " & strLastName
objSelection.Font.Bold = False
objSelection.TypeParagraph()
objSelection.TypeText strTitle
objSelection.TypeParagraph()
objSelection.TypeText strCompany
objSelection.TypeParagraph()
objSelection.TypeText "tel.:  (+33)" & strPhone
objSelection.TypeParagraph()
objSelection.TypeText "fax.:  (+33)" & strFax
objSelection.TypeParagraph()
objSelection.Hyperlinks.Add objSelection.range, "mailto:" & strMail, , , strMail
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.Hyperlinks.Add objSelection.Range, "  ", , , "", "_blank"
objSelection.Font.Bold = False
objSelection.TypeParagraph()
objSelection.TypeText  ""
objSelection.TypeParagraph()
objSelection.TypeText  strZip & " " & strAddress & " " & strCity & " -  FRANCE"
objSelection.TypeParagraph()



objSelection.TypeText "______________________"
objTable.Columns(2).Width = objWord.InchesToPoints(0)




 




 



objSignatureEntries.Add "Signature", objRange
objSignatureObject.NewMessageSignature = "Signature"
objSignatureObject.ReplyMessageSignature = "Signature"



objDoc.Saved = True
objWord.Quit
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
piertomjack Messages postés 4 Date d'inscription vendredi 18 avril 2008 Statut Membre Dernière intervention 21 avril 2008
21 avril 2008 à 16:13
je crois que j'ai trouvé moi même la solution : créer un fichier html ! ( oui j'ai honte...)
bon je donne mon code si ça peut en aider quelques uns :




On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")


strUser = objSysInfo.UserName


Set objUser = GetObject("LDAP://" & strUser)




strName = objUser.FullName
strFirstName = objuser.givenName
StrLastName = objuser.sn
strTitle = objUser.Title
strDepartment = objUser.Department
strCompany = objUser.Company
strAddress = objuser.streetAddress
strCity = objuser.l
strState = objuser.st
strZip = objuser.postalCode
strPhone = objUser.telephoneNumber
strMobilePhone = objUser.mobile
strMail = objuser.mail
strWeb = objuser.wWWHomePage
strFax = objUser.faxNumber


 


IF (strPhone=" " OR strphone = Null OR IsEmpty(strPhone)) THEN strPhone2 = InputBox("Veuillez entrer votre numero de téléphone                                            cliquez sur ""annuler"" pour laisser le champs vide") ELSE strPhone2=strPhone
IF (strMobilePhone=" " OR strMobilePhone = Null OR IsEmpty(strMobilePhone)) THEN strMobilePhone2 = InputBox("Veuillez entrer votre numero de téléphone portable                                    cliquez sur ""annuler"" pour laisser le champs vide") ELSE strMobilePhone2=strMobilePhone
IF (strFax=" " OR strFax = Null OR IsEmpty(strFax)) THEN strFax2 = InputBox("Veuillez entrer votre numero de Fax                                      cliquez sur ""annuler"" pour laisser le champs vide") ELSE strFax2=strFax




Dim objFSO, objWsh, appDataPath, pathToCopyTo, plainTextFile, plainTextFilePath, richTextFile, richTextFilePath, htmlFile, htmlFilePath
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWsh = CreateObject("WScript.Shell")
appDataPath = objWsh.ExpandEnvironmentStrings("%APPDATA%")
pathToCopyTo = appDataPath & "\Microsoft\Signatures"




'HTML signature
htmlFilePath = pathToCopyTo & "Default.htm"
Set htmlFile = objFSO.CreateTextFile(htmlFilePath, TRUE)
htmlfile.WriteLine("<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">")
htmlfile.WriteLine("<META http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">")
htmlfile.WriteLine("<META content=""MSHTML 6.00.6000.16640"" name=GENERATOR></HEAD>")


htmlfile.WriteLine("")
htmlfile.WriteLine("
&nbsp;
<TABLE style=""FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Verdana' "" height=30 cellSpacing=0 cellPadding=2 align=left border=0>----,
<HR align=center width=\"\"100%\"\" color=#0000 noShade SIZE=1>
</TD>\")
htmlfile.WriteLine(\"----
\")
htmlfile.WriteLine(\", <MAP name=Map></MAP\">http://www.monsite.html\"\"></MAP>\")
htmlfile.WriteLine(\"" & strFirstName & " " & StrLastName & "")
htmlfile.WriteLine("
" & strTitle )
htmlfile.WriteLine("
" & strDepartment )
IF Len(strPhone2) > 0 THEN htmlfile.WriteLine("
Tel. &nbsp: (+33) " & strPhone2)
IF Len(strMobilePhone2) >0 THEN htmlfile.WriteLine("
Port.: (+33) " & strMobilePhone2)
IF Len(strFax2)>0 THEN htmlfile.WriteLine("
Fax &nbsp: (+33) " & strFax2)
htmlfile.WriteLine("
" & strMail & "")
htmlfile.WriteLine("

")
htmlfile.writeLine("mon site">www.monsite.html"">mon site
lieu
" & strZip & " " & strCity & "-" & strState)
htmlfile.WriteLine("----,
<HR align=center width=\"\"100%\"\" color=#0000 noShade SIZE=1>
</TD>
</TD></TR><TR></TR></TBODY></TABLE>")
htmlfile.WriteLine("Please consider the environment before printing this mail ! </italique></TD>
")
htmlfile.WriteLine("</TD></TR></TABLE>
&nbsp;
")
htmlfile.Write("</html>")
0
Rejoignez-nous