Print Page | Close Window

Extracting image from email

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5195
Printed Date: 30 March 2026 at 11:00pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Extracting image from email
Posted By: pmormr
Subject: Extracting image from email
Date Posted: 21 August 2003 at 8:56pm
I'm trying to save myself some time by writing a script that adds comics to my database for me. The only problem is that all the comic <img src=... tags are located in emails. Just to add to the headache, the emails have ads of varying lengths, so that rules out a goto line type function. Also, there is more than one <img src... tag. Any Ideas (If you want the email soure i'll post it, it's quite lengthy...)

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Replies:
Posted By: Phat
Date Posted: 21 August 2003 at 9:51pm
Does the comic always have a certain type of name?

-------------
http://buildit.sitesell.com/sitebuildithome.html - Get a website that sells


Posted By: pmormr
Date Posted: 22 August 2003 at 8:22am
The comic image tag reads "<IMG SRC="http://www.funnymail.com/webdata/cs/20030502.gif">". Notice that the numbers in the filename are the date. The rest stays the same.

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Phat
Date Posted: 22 August 2003 at 9:10am

You can then extract all the image tags and from there narrow it down to todays date.

I did a similar type of thing for a web page in VB.

Not sure if ASP has it but use Instr() to find <IMG SRC= then move through the text until you find the ">" tag then you will be left with the img path.

Each time you find a pic you will need to remove that part of the text so next time Instr() will find a new pic.

 



-------------
http://buildit.sitesell.com/sitebuildithome.html - Get a website that sells


Posted By: pmormr
Date Posted: 22 August 2003 at 9:19am
now just to add a new problem. I want to download that picture and save it onto my computer, and add it to a database. I got the second part i just need to know how to download the picture.

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Phat
Date Posted: 22 August 2003 at 4:31pm

You may be able to use file system to save as xxx.xxx on your hard drive. This will only work if the email is on your hard drive already. Then save the path to the file in your db not the pic.

Are you doing this in VB or ASP?
Where is the email source remote or local?



-------------
http://buildit.sitesell.com/sitebuildithome.html - Get a website that sells


Posted By: pmormr
Date Posted: 22 August 2003 at 5:48pm
I'm coding in ASP. I've finally got the search to work! It finds all the image sources without problem. The email source is on my local harddrive. I think i should go and search for a component or something that downloads stuff from the internet.

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Mart
Date Posted: 23 August 2003 at 3:50am

You already have one that should do the trick, do a google for 'microsoft xmlhttp' Use that to get the data and filesystem object to save it on your hdisk.

Mart.



Posted By: Mart
Date Posted: 23 August 2003 at 3:50am
Here is a good example of xmlhttp http://earthskater.com/devzone/asp/xmlhttp.asp - http://earthskater.com/devzone/asp/xmlhttp.asp


Posted By: pmormr
Date Posted: 23 August 2003 at 4:28pm
i just remembered when those pics load their saved to cache... so i can pull them from there, and change the file names...

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 23 August 2003 at 4:29pm
i'll give the xml http thing a try to make it totally humanless though.

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 23 August 2003 at 7:13pm

i'm trying to use the xml thing. This is the function i'm using

Function fetch(url, dest)
      xml.open "GET", url, false
   xml.send
   Dim content
   content = xml.responsetext
   If xml.status = 200 then
      fetch = false
   Exit Function
   End If
   str.type = 1
   str.open
   str.write content
   str.savetofile dest, 2
   End Function  

when i pass http://www.funnymail.com/webdata/cs/20030428.gif - http://www.funnymail.com/webdata/cs/20030428.gif and "c:\comics\241.gif" into the function it gives me the error...

Microsoft JET Database Engine error '800401e4'

No current record.

/scripts2save/comicadder.asp, line 76

line 76 is 'xml.send'. Any ideas?



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net