For Programmers: Free Programming Magazines  


Home > Archive > ASP > December 2006 > sending mail with images









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author sending mail with images
Giorgio

2006-12-11, 6:57 pm

Hi,
I'm using ASP 3 and I send mail with CDONTS.NewMail or CDO.Message.
If my mail contains some html code with images like <img src="URL">, OE
blocks image's visualization.
If i want to avoid this, when i send my mail from OE i flag "send images
with message" option.
How can i realize this when i send the mail with ASP?

Thanks


Giorgio

2006-12-11, 6:57 pm

I'm looking AttachURL method.

objMail.AttachURL Source, ContentLocation

But it seems not to work if i put in Source a path like
http://www.google.it/intl/it_it/images/logo.gif


eddyger

2006-12-11, 6:57 pm

Hi,
view below (i have tested it successfuly ):


messageHTML = "<BODY><CENTER><IMG src=" + IMAGEFILE + " />"
messageHTML = .....

sendMailHtml("from@me.com" ,"to@you.com" , "TEST" , messageHTML)

Sub sendMailHtml(emetteur, destinataire, sujet, message)
Dim objMAIL
Dim cheminImage
Dim objShell

set objShell = CreateObject("WScript.Shell")
cheminImage = objShell.CurrentDirectory + "\" + IMAGEFILE

set objMAIL = CreateObject("CDO.Message")
objMAIL.From = emetteur
objMAIL.To = destinataire
objMAIL.Subject = sujet
objMAIL.HTMLBody = message

objMAIL.AddRelatedBodyPart cheminImage , IMAGEFILE ,
CDOCdoReferenceTypecdoRefTypeId

objMAIL.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMAIL.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtphost"
objMAIL.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMAIL.Configuration.Fields.Update
On Error Resume Next
objMAIL.Send

If Err.Number <> 0 Then

'Wscript.echo "Erreur : " + Cstr(Err.Number) + " ," +
Err.Description
On error goto 0

End if

End Sub

Giorgio

2006-12-11, 6:57 pm

> set objMAIL = CreateObject("CDO.Message")

Thanks, but it works only on IIS..
Is it possible to use CDONTS and use a web path like this
http://www.google.it/intl/it_it/images/logo.gif to attach an image?


Anthony Jones

2006-12-11, 6:57 pm


"Giorgio" <dac@sa.it> wrote in message
news:457bee0c$0$22382$4fafbaef@reader2.news.tin.it...
>
> Thanks, but it works only on IIS..


What do you want it to work 'on'?

> Is it possible to use CDONTS and use a web path like this
> http://www.google.it/intl/it_it/images/logo.gif to attach an image?
>


CDONTS is deprecated, why is using CDOSYS a problem?


Giorgio

2006-12-11, 6:57 pm

> What do you want it to work 'on'?
on a web site that supports asp 3


> CDONTS is deprecated, why is using CDOSYS a problem?

i'm interested in that AttachURL method
objMail.AttachURL Source, ContentLocation
but it works only if "Source" is Server.MapPath ("filename")
and not working if "Source" is a link like http://www...
By the way, which way do you suggest using with CDOSYS?


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com