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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

link in email

Status
Not open for further replies.

gfrlaser1

Technical User
Jan 31, 2013
28
US
I currently have my email body written as:


oMsg.HTMLBody = [<html><font face = "Arial">];
+ [<font size = 2> <font color = 0><br>S:\Postal Documents<br><br>S:\Container Tags<br><br>Y:\Inkjet Files<br><br>W:\FS\MailDat <br><br>Maildate - &mdue<br><br>Quantity - &mquan<br></font></html>]
OMsg.Display()

What I want is for the "[highlight #3465A4]s:\postal Documents[/highlight]" to translate as a clickable link for the recipient in thier email. I have tried all variations of html code to make this possible but fail to find the right combination. Does anyone know the proper way to format this line?
 
It would be helpful if you could tell us what you have already tried.

In general, you format a clickable link like this:

Code:
<a href="[URL unfurl="true"]http://www.MyURL.com">My[/URL] anchor text</a>

But that's so basic that I assume you already know that. After all, you have correctly added all the other HTML to the message.

Also, I assume you understand that[tt] s:\postal Documents[/tt] cannot itself be the target of a link in an email. It has to be a URL. You might possibly be able to use[tt] file://s:\postal Documents[/tt], but only if the recipient has access to the drive and directory in question (and, even then, I'm not sure if it will work).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
In fact, I've now tried [tt] file://s:\postal Documents[/tt]. The mail client correctly recognises it as a clickable hyperlink. However, it only has any effect if it represents a file, not a folder. So either you need a file named [tt]postal documents[/tt] (without an extension), or you need to link to something like[tt] file://s:\postal Documents\MyFile.htm[/tt].

Of course, the recipient must also be able to see the path to the file. In this case, that means that the S drive must be mapped to the correct location.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
No, the problem is not, that a file:// link must be a file, it also can be a folder, but spaces are not allowed in a URL. You have to URL-Encode this to file://s:\postal%20Documents and then can open a folder with that file link.

Bye, Olaf.
 
Ah.. yes, would have been helpful for you to know. Yes, the recipient has access to the folder.
 
Got so tied up in other projects I havent had a chance to get back to it. I will let you know! Thanks for the help everyone.
 
Finally have a chance to revisit this issue. It works! To a point. I am recieving and error of an unrecognized phrase or command in the statement. For the life of me I am not sure what keyword it is.

oMsg.HTMLBody = [<html><font face = "Arial">];
+ [<font size = 2> <font color = 0><br><a href="S:\postal%20Documents">S:\postal Documents</a><br><br><a href="S:\Container%20Tags">S:\Container Tags</a><br><br><a href="Y:\inkjet%20files">Y:\Inkjet Files</a><br><br><a href="W:\FS\Maildat">W:\FS\Maildat</a><br><br>Maildate - &mdue<br><br>Quantity - &mquan<br></font></html>]
OMsg.Display()

sure appreciate the help you guys through my way.
 
That's an easy one. Your string is too long. VFP has a limit of 255 characters for a string literal. Your second literal [tt]([<font size = 2> ....</font></html>][/tt] is 323 characters.

The solution is to split it into several separate strings. Alternatively use the TEXT / ENDTEXT construct, which also has the advantage of being easier to read.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mikes advice put as code, means:

Code:
TEXT TO oMsg.HTMLBody NOSHOW
<html><font face = "Arial">
<font size = 2> <font color = 0><br>
<a href="file://S:\postal%20Documents">S:\postal Documents</a><br><br>
<a href="file://S:\Container%20Tags">S:\Container Tags</a><br><br>
<a href="file://Y:\inkjet%20files">Y:\Inkjet Files</a><br><br>
<a href="file://W:\FS\Maildat">W:\FS\Maildat</a><br><br>
Maildate - <<mdue>><br><br>Quantity - <<mquan>><br>
</font></html>
ENDTEXT
oMsg.Display()

I also changed some additional details apart of Mike's advice about the string literal length being no problem in TEXT..ENDTEXT:

1. While a Windows Path used as href works in IE and for Outlook recipients, this is just a forgiveness of MS. A href in general has to be a URI and a URI always needs to begin with a protocol, eg "ftp://", " or "file://", the latter even in case of folders, not only for files. If you use the more strict URI, that will also work for recipients using a forward to another mail account, eg Gmail or anything else, as long as they use these links in the LAN, where those paths are correct.
2. As a conclusion of 1: This won't work, when sending it to someone outside of the LAN, you'd have to attach files in that case, but that should be obvious.
3. Another quite obvious point: Even within the same LAN the paths depend on the identical mapping of drives S, Y and W.
4. As I switched to TEXT ENDTEXT I also had to change from macro substitution to the merge expressions, using << and >> delimiters around mdue and mquan.

Bye, Olaf.
 
Cool. That makes sense. It just didn't seem the lines were as long as they were. Something to remember. TEXT .ENDTEXT is good to learn about also. Luck has it I don't require too much with creating scripts for email, just this one and I should be good.. This should do me great now. Again, thanks so much for all the help.
 
>It just didn't seem the lines were as long as they were
Well, just select your string from <html> to </html> copy the selection via CTRL+C and get the clipboard length via ? LEN(_cliptext) and you get over 300 chars. It's the length including all text, not the visual length. A string variable can hold up to 16 MB text, that is not the problem, but a string - a string in source code from [ to ] or ' to ' or " to " can only have 254 chars at one part, you can break and concatenate, eg "254 chars"+"another 254 chars"+... etc. But it's much easier and easier to read to use TEXT..ENDTEXT and the final string already contains CHR(13)+CHR(10) at line breaks, too.

Bye, Olaf.
 
Olaf, I understand having to use merge expressions, but I must be missing one additonal point somewhere. The resulting email body copy looks like this:

S:\postal Documents

S:\Container Tags

Y:\Inkjet Files

W:\FS\Maildat

Maildate - <<mdue>>

Quantity - <<mquan>>

Do I somehow need to place a symbol to identify it as the stored variable? Like "&" ? I have stored a date to mdue and a text value to mquan prior to generating the email body copy.
 
It looks like you have changed the settings for the text merge delimiters. By default, these are[tt] <<[/tt] and [tt]>>[/tt], but those symbols are still in your generated text.

Have you issued a [tt]SET TEXTMERGE DELIMITERS[/tt] command to change the default delimiters? If so, that would explain why the code that Olaf showed you doesn't work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
here is the entire block of code:

TEXT TO oMsg.HTMLBody NOSHOW
<html><font face = "Arial">
<font size = 2> <font color = 0><br>
<a href="file://S:\postal%20Documents">S:\postal Documents</a><br><br>
<a href="file://S:\Container%20Tags">S:\Container Tags</a><br><br>
<a href="file://Y:\inkjet%20files">Y:\Inkjet Files</a><br><br>
<a href="file://W:\FS\Maildat">W:\FS\Maildat</a><br><br>
Maildate - <<mdue>><br><br>Quantity - <<mquan>><br>
</font></html>
ENDTEXT
oMsg.Display()
 
Sorry, I forgot one option. It has to be TEXT TO oMsg.HTMLBody NOSHOW TEXTMERGE.
Also take a look at the help topic.

Bye, Olaf.
 
SET TEXTMERGE ON is leading nowhere in case of TEXT..ENDTEXT. It's there to control how \ and \\ will merge text or not (\ and \\ work about the same way as ? and ??, but can merge texts and be redirected to a file)

TEXT..ENDTEXT sections are easier to use than that. Also notice for the small one line merging text with variables and other expressions you can use Textmerge() as function, so you have three ways for text merging. The TEXTMERGE setting ON/OFF only set's on or off text merging done by \ and \\.

Bye, Olaf.
 
Olaf,

Are you saying that SET TEXTMERGE ON only controls \\ and not the << and >> delimiters in a TEXT / ENDTEXT? If so, that's not my understanding.

I'm saying that, for example, the following will correctly display the date:

Code:
SET TEXTMERGE ON 
TEXT TO lcTest NOSHOW 
This is a test on <<DATE()>>.
ENDTEXT

That's the point I was making in my previous post.

However, I agree that it's better to use the TEXTMERGE clause in the TEXT TO ... command. But that's because the effect is local to that command. If you issue SET TEXTMERGE ON, you have to remember to put it back to what it was before when you have finished with it.

If I've misunderstood what you are saying, I apologise and will go back to sleep.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top