I'm using a variable for the body in the SMTPSendMail command. There are commas in the string and everything after the first comma gets cut off. How can I keep the commas? Example:
Let>bigbody=Please send me $1,500,000 in cash
SMTPSendMail>To,Server,FromAddress,FromName,Subject,bigbody
The body of the email ends up like this:
Please send me $1
Thanks in advance for your help.
using commas in the body of the SMTPSendMail command
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You've missed off the last parameter - attachments. You need a final comma (followed by nothing as you have no attachments):
Let>bigbody=Please send me $1,500,000 in cash
SMTPSendMail>To,Server,FromAddress,FromName,Subject,bigbody,
That works.
Let>bigbody=Please send me $1,500,000 in cash
SMTPSendMail>To,Server,FromAddress,FromName,Subject,bigbody,
That works.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
While the example given works, it is not a complete solution
I'm trying to send some email, and I'm getting thwarted by commas in the body too. I'm able to get the example in the answer above to work, but when it gets more complicated than that, it doesn't work.
This is mission-critical. How do I fix it?
This is mission-critical. How do I fix it?
Code: Select all
//MessageModal>This macro demonstrates how to send Email & Files using the SMTPSendMail command.
Let>SENDMAIL_STATUS=1
Let>SMTP_HTMLBODY=1
Let>SMTP_SSL=1
Let>SMTP_AUTH=1
Let>SMTP_USERID=**************
Let>SMTP_PASSWORD=********
LabelToVar>Welcome0,msg0
/*
Welcome0:
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
a.button2{
display:inline-block;
padding:0.5em 3em;
border:0.16em solid #FFFFFF;
margin:0 0.3em 0.3em 0;
box-sizing: border-box;
text-decoration:none;
text-transform:uppercase;
font-family:'Roboto',sans-serif; /* <------ this comma right here is what cuts off the message */
font-weight:400;
color:#FFFFFF;
text-align:center;
transition: all 0.15s;
}
a.button2:hover{
color:#DDDDDD;
border-color:#DDDDDD;
}
a.button2:active{
color:#BBBBBB;
border-color:#BBBBBB;
}
@media all and (max-width:30em){
a.button2{
display:block;
margin:0.4em auto;
}
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<a href="something" class="button2">Button</a>
<a href="something" class="button2">Very pretentious long button</a>
Oh, and a comma will fail down here too.
</body></html>
*/
//MessageModal>msg
//GoTo>end
Let>smtp=smtp.gmail.com
Let>fromname=********
Let>fromemail=**********
Let>toemail=************
Let>subject=Comma Trouble!
SMTPSendMail>toemail,smtp,fromemail,fromname,subject,%msg0%,
//MessageModal>SMTP_RESULT
MidStr>SMTP_RESULT,1,3,ErrCode
If>%ErrCode%=250
//Do Nothing
Endif
Label>end
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: using commas in the body of the SMTPSendMail command
Remove the % signs from msg0. You're not embedding anything there. The variable should be on it's own:
SMTPSendMail>toemail,smtp,fromemail,fromname,subject,msg0,
SMTPSendMail>toemail,smtp,fromemail,fromname,subject,msg0,
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: using commas in the body of the SMTPSendMail command
Yes, that seems to have worked, thank you. I'm not sure I understand why this is necessary.
This line is from your example code:
Is this variable embedded? I don't quite understand the difference.
This line is from your example code:
Code: Select all
SMTPSendMail>toemail,smtp,fromemail,fromemail,subject,%msg%,attach
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: using commas in the body of the SMTPSendMail command
You're right, it shouldn't make a difference and I'm looking into that now. However, when referencing a variable on its own my rule of thumb is not to use % symbols. I only use them if I want to reference the variable within another string.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?