Error » Web Related Error!! » Server Side Languages Error ! » In mailto: how can I use the & character in the body?

Server Side Languages Error ! Post here with questions about PHP, perl/cgi, ASP, etc.

Post New Thread Reply
  In mailto: how can I use the & character in the body?
LinkBack Thread Tools Display Modes
Old 12-Jan-2007, 01:51 AM   #1 (permalink)
Administrator
 
Admin's Avatar

Posts: 876
Join Date: Oct 2005
Rep Power: 10 Admin has disabled reputation

IM:
Default In mailto: how can I use the & character in the body?

I'm using mailto: to open the default mail program and would like to populate it automatically with the to field, the subject and the body.

I'm experiencing problems if the body contains the & character.

for example if I type: mailto:myname@mydomain.com?subject=Test&body=http://www.mywebsite.com?param1=10&param2=20

I get the following body:
http://www.mywebsite.com?param1=10

I also tried typing
mailto:myname@mydomain.com?subject=Test&body=http://www.mywebsite.com?param1=10%26param2=20

but I'm always getting the same wrong result. (The body is truncated as I get to the & symbol).

I've tried this with Eudora.
Any suggestion on how to fix this?

Solution:

You are going to have problems with this and it probably won't work. The ampersand (&) is a special character in the URL. You can use the ascii code for it but the mail client will probably not translate it for you. The body won't be html so & won't work either.

Are you really sure that you want to use mailto? I would recommend avoiding it at all costs. It is poorly supported by mail clients and works with few online email accounts. It will also expose the email and other personal info to bots, etc that can get it from your HTML. Finally, it requires the visitor to use their email program and account when they may not want to.

If your server supports a server language then you can easily develop a better option with it to send the email. This is a much better option. Let me know if you want more info on it or have questions.

The server solution will fix this problem since the server can write the message body with the ampersand.

Let me know if you have any questions or need more information.


also


The options you tried would be the ones that have a chance of working. If you want you could try another email program. Some of the recent versions have dropped support for mailto completely and many had only limited support for the body. If the mail program doesn't matter then you may find one that will work. The & sign should not ever work but you may be able to use the ascii code.

Are you trying to send a bulk email or why do you need it automated? I ask to see if I can suggest a better option than Direct Access and mailto.
Admin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
   


   
Old 12-Jan-2007, 01:51 AM   #2 (permalink)
Administrator
 
Admin's Avatar

Posts: 876
Join Date: Oct 2005
Rep Power: 10 Admin has disabled reputation

IM:
Default Re: In mailto: how can I use the & character in the body?

This I can confirm works fine with Outlook 2003, and Gmail Notifier for Windows:
www.mywebsite.com%3Fparam1%3D10%26param2%3D20">Send email
Admin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Post New Thread Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -8. The time now is 12:19 PM.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

DMCA Policy

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228