Sign in to follow this  
Followers 0
nevodj

variable being split on '&' character

9 posts in this topic

this is the body from the function _InetMail

$s_MailBody = "To track your order click here: " & @CRLF & $url

I have a problem, if the url has a '&' sign in it, it rips off everything after the '&' in the url for obvious reasons.

how do i stop this?

thanks

James

Share this post


Link to post
Share on other sites



this is the body from the function _InetMail

$s_MailBody = "To track your order click here: " & @CRLF & $url

I have a problem, if the url has a '&' sign in it, it rips off everything after the '&' in the url for obvious reasons.

how do i stop this?

thanks

James

Not obvious to me but it depends on what you are doing with $s_MailBody. If you do this for example

ConsoleWrite("1234" & "56 & 78" & @CRLF)

then you get the ampersand as expected.

Maybe try enclosing the url in quotes like this

$s_MailBody = "To track your order click here: " & @CRLF & '" & $ur & '"'

or, if the string is used in HTML code then you need to use

&amp

instead of

&

to represent the ampersand, so

$url = StringReplace($url, "&", "&amp")


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

thanks.. i can't get either of these options to work.

an example of the URL would be http://www.fastway.org/Magic94Scripts/mgrqispi94.dll?appname=FW&prgname=PodR

esultNew&arguments=-A4Z00056245145%2C-N1%2C-AN

when autoit is pushing this thru it thinks the & in the URL is the end of the string? i dont really know how to explain it.

it would be trying to do "http://www.fastway.org/Magic94Scripts/mgrqispi94.dll?appname=FW" &prgname=PodR

esultNew & arguments=-A4Z00056245145%2C-N1%2C-AN

therefore losing averything after the ampersand.

Share this post


Link to post
Share on other sites

&Amp should probably do it but martin has it wrong. It's actually &

he left of the semi-colon.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Try putting 2 quote marks after the $url like below, it might also be a problem with the way you are declaring $url

$s_MailBody = "To track your order click here: " & @CRLF & $url & ""

Share this post


Link to post
Share on other sites

thanks for your help fellas

Tried all these options. this is the way the variables are being declared.

_Sql_GetTableAsString($oADODB,"SELECT X_TRACEURL FROM SALESORD_HDR WHERE SEQNO = " & $seqno & ";",$vString)
$url = StringTrimLeft($vString, 10)

Func emaildets()
    $url = StringReplace($url, "&", "&")
    $s_MailTo = $email
    $s_MailSubject = "Consignment Tracking Details for Order Number " & $orderno
    $s_MailBody = "Below are the consignment details for your order number " & $orderno & @CRLF & "Carrier: " & $carrier & @CRLF & "Con Note Number: " & $connote & @CRLF & @CRLF & "To track your consignment click here: " & @CRLF & $url & ""
    _INetMail ( $s_MailTo, $s_MailSubject, $s_MailBody )
EndFunc

i am pushing the same $url thru to IE and it works fine using:

$oIE = _IECreateEmbedded()

$GUIActiveX = GUICtrlCreateObj($oIE, 10, 45, 980, 600)

_IENavigate ($oIE, $url)

Share this post


Link to post
Share on other sites

Try

$s_MailBody = "Below are the consignment details for your order number " & $orderno & @CRLF & "Carrier: " & $carrier & @CRLF & "Con Note Number: " & $connote & @CRLF & @CRLF & "To track your consignment click here: " & @CRLF & $url & "    "

( Couple spaces added to the last " " )


Share this post


Link to post
Share on other sites

thanks for your help fellas

Tried all these options. this is the way the variables are being declared.

_Sql_GetTableAsString($oADODB,"SELECT X_TRACEURL FROM SALESORD_HDR WHERE SEQNO = " & $seqno & ";",$vString)
$url = StringTrimLeft($vString, 10)

Func emaildets()
    $url = StringReplace($url, "&", "&")
    $s_MailTo = $email
    $s_MailSubject = "Consignment Tracking Details for Order Number " & $orderno
    $s_MailBody = "Below are the consignment details for your order number " & $orderno & @CRLF & "Carrier: " & $carrier & @CRLF & "Con Note Number: " & $connote & @CRLF & @CRLF & "To track your consignment click here: " & @CRLF & $url & ""
    _INetMail ( $s_MailTo, $s_MailSubject, $s_MailBody )
EndFunc

A solution (dirty way) :huh2:

Open Inet.au3 include and replace this line on function _INetExplorerCapable

Before:

If $n_IEChar < 0x21 Or $n_IEChar = 0x25 Or $n_IEChar = 0x2f Or $n_IEChar > 0x7f Then

After:

If $n_IEChar < 0x21 Or $n_IEChar = 0x25 Or $n_IEChar = 0x26 Or $n_IEChar = 0x2f Or $n_IEChar > 0x7f Then

Now replace function _INetMail with this:

Func _INetMail($s_MailTo, $s_MailSubject, $s_MailBody)
    Local $prev = Opt("ExpandEnvStrings", 1)
    Local $var = RegRead('HKCR\mailto\shell\open\command', "")
    $s_MailTo=_INetExplorerCapable($s_MailTo)
    $s_MailSubject=_INetExplorerCapable($s_MailSubject)
    $s_MailBody=_INetExplorerCapable($s_MailBody)
    Local $ret = Run(StringReplace($var, '%1', 'mailto:' & $s_MailTo & '?subject=' & $s_MailSubject & '&body=' & $s_MailBody))
    Local $nError = @error, $nExtended = @extended
    Opt("ExpandEnvStrings", $prev)
    Return SetError($nError, $nExtended, $ret)
EndFunc   ;==>_INetMail

It is working for me. I hope it helps.

Share this post


Link to post
Share on other sites

A solution (dirty way) Posted Image

Open Inet.au3 include and replace this line on function _INetExplorerCapable

Before:

If $n_IEChar < 0x21 Or $n_IEChar = 0x25 Or $n_IEChar = 0x2f Or $n_IEChar > 0x7f Then

After:

If $n_IEChar < 0x21 Or $n_IEChar = 0x25 Or $n_IEChar = 0x26 Or $n_IEChar = 0x2f Or $n_IEChar > 0x7f Then

Now replace function _INetMail with this:

Func _INetMail($s_MailTo, $s_MailSubject, $s_MailBody)
    Local $prev = Opt("ExpandEnvStrings", 1)
    Local $var = RegRead('HKCR\mailto\shell\open\command', "")
    $s_MailTo=_INetExplorerCapable($s_MailTo)
    $s_MailSubject=_INetExplorerCapable($s_MailSubject)
    $s_MailBody=_INetExplorerCapable($s_MailBody)
    Local $ret = Run(StringReplace($var, '%1', 'mailto:' & $s_MailTo & '?subject=' & $s_MailSubject & '&body=' & $s_MailBody))
    Local $nError = @error, $nExtended = @extended
    Opt("ExpandEnvStrings", $prev)
    Return SetError($nError, $nExtended, $ret)
EndFunc   ;==>_INetMail

It is working for me. I hope it helps.

Thanks, this fixes the problem. Only problem is now it creates two emails!

The first one is what i want, the subject of the email is right, the second email the body is blank and the subject reads like this:

"Consignment Tracking Details for Order Number Q1434&body=Below are the consignment details for your order number Q1434"

any ideas?

thanks

Nevodj

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0