Reputation: 23
I have a script designed to ask for the subject of an email address, and then send an email using that subject, the entire script works fine, except for some reason, it sends the variables name (i.e %subject%) as opposed to what I set it to, earlier in the script. I know the variable successfully saves, because i had it display the variable after the user's input. When i recieve the email, it gives %subject% as the subject name, even if i set it to something else, i think the problem lies within the variable being within quotes in the script
pmsg.Subject := "%subject%"
The subject has to be within quotes for the script to work.
Upvotes: 1
Views: 1324
Reputation: 6371
Ah, I've had that problem too. So I made this function and keep it in my ahk library:
;simply enclose the text in double-quotes
;if you set mode, the string is surrounded by doubled double quotes
enc(whattext, mode=0){
global a_doublequote
if(mode){
quotedvar = "%a_doublequote%%whattext%%a_doublequote%"
}else{
quotedvar := a_doublequote . whattext . a_doublequote
}
return quotedvar
}
Here is the output:
testphrase = george
msgbox % enc(testphrase)
;==> "george"
msgbox % enc(testphrase, true)
;==> ""george""
What you are doing with the :=
assignment is creating a string with the value of %subject
pmsg.Subject := "%subject%"
However, it would work if you did this:
pmsg.Subject = "%subject%"
You see, when you use the :=
assignment, the variable is assigned the same way it does in other coding languages, like Javascript. When you just use =
then the variable is assigned in literal mode except for the %
which denotes variable assignment in that mode.
Upvotes: 0
Reputation: 1450
Maybe you can try it like this
pmsg.Subject := subject
or if you need the quotes
try it like this
pmsg.Subject := """ . subject . """
Hope it helps
Upvotes: 1