I am trying to generate an email from a button click. I am using the script editor in the event handler for said button. Below is the code I am using. I am receiving no error but also no emails when clicking the button. This is being done in Vision. Am I missing something in code or is this something I need to add or change in the gateway. We currently have other projects generating emails so I am guessing it is my code.
import system
def onButtonClick(event):
# Get the email address of the recipient.
recipient = "email@email.com"
# Get the subject of the email.
subject = "This is the subject of the email."
# Get the body of the email.
body = "This is the body of the email."
# Get the default SMTP profile for the Gateway.
smtpProfile = system.net.getSMTPProfile()
# Send the email.
system.net.sendEmail(recipient, subject, body, smtpProfile)
I cant find this in the documentation, and have you checked the logs from the gateway logs page?
I believe if you don't supply the parameter names then the order is important, i like to set things up like this example from the documentation.
body = "<HTML><BODY><H1>This is a big header</H1>"
body += "And this text is <font color='red'>red</font></BODY></HTML>"
recipients = ["bobsmith@mycompany.com", "1235558383@vtext.com", "sally@acme.org", "1235557272@vtext.com"]
cc_recipients = ["annejones@mycompany.com"]
smtp_server = "mySmtpServer"
system.net.sendEmail(smtpProfile=smtp_server, fromAddr="myemail@mycompany.com", subject="Here is the email!", body=body, html=1, to=recipients, cc=cc_recipients)
I tried a copy paste of your code and substituted the emails and the smtp server. When I click ok it accepts it in the designer I switch to preview mode and click the button and no error occurs in the designer. When I check the log files on the gateway I do not see anything as well. I can send myself a test email from the smpt server but for some reason it will not send from the button click in the vision designer.
There is no white space before, or after. This is currently working to send out emails for another project. I am trying to see if I can find something different between my project and the one that is functioning, but have not had any luck yet.