Hot Topic (More than 10 Replies) @SendMail question (Read 3937 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
@SendMail question
Oct 31st, 2009 at 1:22am
Print Post Print Post  
The following code works great to send an email.

vSubject = Coachmessage
vFromEmail = "myemail.net"
vToEmail = vCEmail
vCBody = coachmessage

iia = @SendMail("smtp.charter.net", vSubject, vFromEmail, vToEmail, "", "", vCBody, "", "", "")

I’d like to change vSubject to accept variables like shown below, so that it would become “automatic” if you will.  When I do change it, it works great, but then the body area of the email designated as vCBody here, does not work any longer (Does not get emailed) although the email does get sent.

vSubject = ("Dear coach" + " " + vCLast + " " + "please call these players")      
     
iia = @SendMail("smtp.charter.net", vSubject, vFromEmail, vToEmail, "", "", vCBody, "", "", "")

It almost seems as though there’s not enough time for Sesame to “grab” both the vSubject data and the vCBody data before the emailing takes place.

Also, when I address the email to more than one recipient dividing the addresses using a “;” it works sporadically.  In other words, sometimes the email goes through and other times it does not. Could this be a timing thing also?

Thanks for any help with this.
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SendMail question
Reply #1 - Oct 31st, 2009 at 3:41am
Print Post Print Post  
tcgeo wrote on Oct 31st, 2009 at 1:22am:
The following code works great to send an email.

vSubject = Coachmessage
vFromEmail = "myemail.net"
vToEmail = vCEmail
vCBody = coachmessage

iia = @SendMail("smtp.charter.net", vSubject, vFromEmail, vToEmail, "", "", vCBody, "", "", "")

I’d like to change vSubject to accept variables like shown below, so that it would become “automatic” if you will.  When I do change it, it works great, but then the body area of the email designated as vCBody here, does not work any longer (Does not get emailed) although the email does get sent.

vSubject = ("Dear coach" + " " + vCLast + " " + "please call these players")      


The outside parentheses are not necessary in the line above. They don't cause a problem, but I am curious as to why you are using them.

Quote:
     
iia = @SendMail("smtp.charter.net", vSubject, vFromEmail, vToEmail, "", "", vCBody, "", "", "")

It almost seems as though there’s not enough time for Sesame to “grab” both the vSubject data and the vCBody data before the emailing takes place.

I don't see anything specifically wrong there, but I doubt timing is an issue. Some mail servers do set a timeout for communications, but the @SendMail command would return an error indicating that the connection timed out. Use a bunch of WriteLn commands to show you the value of the data you are sending. If nothing wrong is seen, double (and triple) check that all of your quotes and commas are in the right places. With ten arguments, many of which are optional, it isn't difficult to get a comma or a double quote out of sorts.

Quote:
Also, when I address the email to more than one recipient dividing the addresses using a “;” it works sporadically.  In other words, sometimes the email goes through and other times it does not. Could this be a timing thing also?

Thanks for any help with this.


As I said above, almost certainly not a timing issue. Instead of placing multiple email addresses in the ToAddr argument (which should be just one main recipient), place them in either the CC or the BCC arguments. The entire email, header and all, is sent as a whole from Sesame to your email server. So if your server does not like having multiple addresses specified in the main ToAddr, it may set the rest of the email header and body out of whack.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @SendMail question
Reply #2 - Oct 31st, 2009 at 2:41pm
Print Post Print Post  
Thanks again for your help Mark.

As to the outside parentheses, I’m not sure why I used them, maybe because @SendEmail does?   I removed them to see if it would make a difference but it didn’t, just like you had indicated.

I used writeln commands as you suggested, all of the data shows correctly.  I can’t seem to find any errors in the code.  I have written and rewritten several times.  Again, when I use one variable or a "hard coded" message in the subject area the mail is sent without trouble.  When I use ("Dear coach" + " " + vCLast + " " + "please call these players") with or without the (), the subject data does not come through in the email although the writeln window reports the correct data.  I also have been using WriteLn(vFlag) to show any errors, it always responds with 0.

I’ll work on the code to get the addresses to use the CC or BCC areas to see if that helps.  In the meantime, when I address using several addresses they are separated by ";".  There is also a “;” following the last address.  I found that if I delete that last “;” the email is sent to all recipients without trouble.

Thanks,

Brandon
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SendMail question
Reply #3 - Nov 1st, 2009 at 2:29pm
Print Post Print Post  
tcgeo wrote on Oct 31st, 2009 at 2:41pm:
I’ll work on the code to get the addresses to use the CC or BCC areas to see if that helps.  In the meantime, when I address using several addresses they are separated by ";".  There is also a “;” following the last address.  I found that if I delete that last “;” the email is sent to all recipients without trouble.


The trailing semicolon must be confusing your email server.

You say that there is no problem when you use a variable or hardcode the subject, but there is a problem when you assign an assembled string to a variable and then use the variable? When you use a variable and it works, what are you assigning to that variable if it is not an assembled string?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @SendMail question
Reply #4 - Nov 1st, 2009 at 6:59pm
Print Post Print Post  
Thanks again for your help Mark, I’ll try to clarify.

When I use:

vSubject = “Test Subject Area”        //This is what I’m calling hard coded,  the email gets sent without error.

vSubject = Email Subject Area        //this gets whatever is typed into the “Email Subject Area” named text editor box on the form and the email is sent without error.

vSubject = ("Dear coach" + " " + vCLast + " " + "please call these players")  //When this assembled string is used for vSubject, the vSubject data gets placed into the subject area of the email correctly (In other words the assembled string works) and the email gets sent. But, what does not get sent with the email is the body portion of the email designated as vCBody here;

iia = @SendMail("smtp.charter.net", vSubject, vFromEmail, vToEmail, "", "", vCBody, "", "", "")

vCBody = coachmessage      //Gets whatever is typed into the “coachmessage” named text editor box on the form.

The short of it is, when I use the assembled string in the vSubject area, the body of the email does not get sent.


Is there code that I haven’t found yet that will remove that last “;” in the string?  This database is being built for the purpose of notifying players of changes in game schedules.  So, the database is searched for all player email addresses for the two schedule teams. Then a mass email is sent to notify all of them of the change.

Thanks,

Brandon
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SendMail question
Reply #5 - Nov 2nd, 2009 at 3:24am
Print Post Print Post  
Is it possible that in some records there is a new line (ascii 13 or 10) or other control character in the field "vCLast"? That would make the email header one or more lines longer, which could upset your email server.

There are quite a few ways to remove a trailing semicolon in a string. A conditional on @right, or, if the semicolon is always there, using @left(str, @len(str) - 1), or other variations on the string scanning routines would do the trick, as would the use of string array functions.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @SendMail question
Reply #6 - Nov 2nd, 2009 at 1:27pm
Print Post Print Post  
I have only one record in the coach’s database and it contains my last name in the vCLast LE.  As far as I can tell it does not contain ascii 13 or 10.

Thanks for the help on removing the “;”.  

Just an observation, I use MS Outlook for my email editor. When I send an email to several recipients, adding them to the “To” address field via My Contacts, the addresses are all followed by a “;” , even the last one, and the emails are sent without error.  Of course I have no Idea what Outlook does with the semicolons once Send is pressed.
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SendMail question
Reply #7 - Nov 2nd, 2009 at 1:48pm
Print Post Print Post  
tcgeo wrote on Nov 2nd, 2009 at 1:27pm:
Just an observation, I use MS Outlook for my email editor. When I send an email to several recipients, adding them to the “To” address field via My Contacts, the addresses are all followed by a “;” , even the last one, and the emails are sent without error.  Of course I have no Idea what Outlook does with the semicolons once Send is pressed.


It probably does quite a bit with everything in the email header before handing it off to the email server.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SendMail question
Reply #8 - Nov 3rd, 2009 at 3:37pm
Print Post Print Post  
I just tried this out using your code on our email server and all worked very well.

The only difference I could see was that our email server requires a login and password. It does not appear that your email server needs a login. Could you post your exact and complete code (use cut and paste), and the values of all relevant fields and variables (use writeln to print them and then cut and paste here)? I tried to piece together what you are doing from the snippets posted here, but it would help to have the actual code in its actual order with all the actual values.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @SendMail question
Reply #9 - Nov 3rd, 2009 at 4:52pm
Print Post Print Post  
Hi Mark,

I solved the problem.

I decided to look for any possible mistake throughout the database.  Looking in Form Attributes I found that the Name and the Label for Coachmessage, the source for vCBody,  are both called Coachmessage,  but the Data Source was called !Coachmessage0. So I must have tried to rename the LE the same name at some point and Sesame followed the name with a zero, and I didn’t pay attention.  So I went into Field Manager and removed the zero and the code works great.

I’m sorry to have wasted your time on this, although I probably never would have found it without you indicating that it should work.

Brandon
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SendMail question
Reply #10 - Nov 3rd, 2009 at 5:32pm
Print Post Print Post  
No problem. Always happy to help.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged