JackHerrer
Messages postés1Date d'inscriptionmardi 31 août 2004StatutMembreDernière intervention20 janvier 2012
-
20 janv. 2012 à 10:37
Nicolas_kojack
Messages postés136Date d'inscriptionvendredi 19 novembre 2004StatutMembreDernière intervention25 mai 2012
-
25 mai 2012 à 14:07
bonjour
je souhaite envoyer un mail en vbs en incluant une image qu'accepterais outlook;
En effet, par defaut outlook bloque les images.
j'ai donc trouver une astuce grace à google :
Const CdoReferenceTypeName = 1
Dim objCDO, objBP
Set objCDO = Server.CreateObject("CDO.Message")
objCDO.MimeFormatted = True
objCDO.To = "you@yourdomain.com"
objCDO.From = "you@yourdomain.com"
objCDO.Subject = "Embedded image demo"
objCDO.HTMLBody = "<html>Check this out: </html>"
' Here's the good part, thanks to some little-known members.
' This is a BodyPart object, which represents a new part of the multipart MIME-formatted message.
' Note you can provide an image of ANY name as the source, and the second parameter essentially
' renames it to anything you want. Great for giving sensible names to dynamically-generated images.
Set objBP = objCDO.AddRelatedBodyPart(Server.MapPath("/images/myimage.gif"), "myimage.gif", CdoReferenceTypeName)
' Now assign a MIME Content ID to the image body part.
' This is the key that was so hard to find, which makes it
' work in mail readers like Yahoo webmail & others that don't
' recognise the default way Microsoft adds it's part id's,
' leading to "broken" images in those readers. Note the
' < and > surrounding the arbitrary id string. This is what
' lets you have SRC="cid:myimage.gif" in the IMG tag.
objBP.Fields.Item("urn:schemas:mailheader:Content-ID") = "<myimage.gif>"
objBP.Fields.Update
objCDO.Send
Mais j'ai un message d'erreur sur l'objet server :
Nicolas_kojack
Messages postés136Date d'inscriptionvendredi 19 novembre 2004StatutMembreDernière intervention25 mai 2012 25 mai 2012 à 14:07
J'arrive avec beaucoup de retard mais le "server" est utilisable en asp pas en vbscript, en VBS tu mets directement CreateObject :
Set objCDO = CreateObject("CDO.Message")
Autre chose la méthode server.mappath n'existe pas en vbscript tu devras utiliser un objet Scripting.FileSystemObject et me semble t'il GetAbsolutePath pour récupérer ton chemin vers le fichier.
A priori sinon comme le dit Djoulzz ton code renvoi une erreur en asp 3.0 de sendusing donc il faut surement balancer de la configuration.