Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Pages in order to send them by e-mail(NewsLetter)

Status
Not open for further replies.

svagelis

Programmer
May 2, 2001
121
GR
Well what i m trying to do is send a page as a newsletter to some emails from my database.
The problem is to convert all image links and text links from relative to http absolute. I mean if image src = '.\images\top.gif' and my domain is ==> 'I want to do this beacause by sending a page to someone with relative links whose links doesnt work.

Any help appreciated !!

Thanks in advance...
 
You could use a Replace function to replace all occurences of the string src='. with the string src='of course than your slashes will still be wrong.
You could write a function to pull out the image tag, alter it, than append it back in.
Code:
Function fixImages(mySource)
   Dim startCnt, endCnt
   Dim workingStr
   startCnt = Instr(mySource,&quot;<img&quot;)

   While startCnt > 0
      endCnt = InStr(startCnt,mySource,&quot;>&quot;,1)
      workingStr = mid(mySource, startCnt, endCnt - startCnt)
      workingStr = Replace(workingStr,&quot;src='.&quot;,&quot;src='[URL unfurl="true"]http://mysite.com&quot;)[/URL]
      workingStr = Replace(workingStr,&quot;\&quot;,&quot;/&quot;)

      mySource = left(mySource,startCnt-1) & workingStr & right(mySource, len(mySource) - endCnt)
      startCnt = InStr(endCnt,mySource,&quot;<img&quot;,1)
Loop

The above code is on the fly, so it may not append the pieces back together 100% coprrectly, may be off by a character or two.
Basically it is looping through all instances of the string starting with &lt;img and ending with &gt;. It replaces the . with a domain and then switches the blashes to slashes. Afterwards it concatenates the working string back where it came from, between the left and right portions of the source.

Hope that helps,
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top