Hi,
I have a question.
I send an email
Void sendNotification(Integer customerId, String emailFor, Integer replyTemplateId)
{
// Load customer
Customer customer;
customer.load(customerId);
Integer customerLanguage = customer.getValue("language").toInteger();
// Load reply template
ReplyTemplate rt;
rt.load(replyTemplateId);
String subject = rt.getSubject(customerLanguage);
String bodyPlain = rt.getPlainBody(customerLanguage);
String bodyHtml = rt.getHtmlBody(customerLanguage);
// Parse templates with customer and ticket
Parser parser = getParser();
customer.toParser(parser);
subject = parser.parseString(subject);
bodyPlain = parser.parseString(bodyPlain);
bodyHtml = parser.parseString(bodyHtml);
// Send email
Email email;
email.setValue("from","ticketsystem@akgsoftware.de");
email.setValue("to", emailFor);
email.setValue("subject", subject);
if (bodyPlain != "")
{
email.setValue("body", bodyPlain);
}
if (bodyHtml != "")
{
email.setValue("bodyHtml", bodyHtml);
}
email.s
email.send();
}
In the fall where the emailadresse not exist, i'm in the customerservice, the content from the email will be show in my html page.
Are this normal ?
Have you got any idea?
Thanks Fabrice
All Replies (2)
Hi Fabrice,
your method should validate that the input parameters are valid and sensible, and if they are not you could choose to either throw an exception or have the method return a value indicating failure to send.
For instance you could do something like this:
Void SendNotification(Integer customerId, String toEmail)
{
if (!toEmail.isValidEmail()) {
throw "Non-valid e-mail address";
}
// The rest of your code here...
}
The code that calls that method should use a try-catch block to capture and handle that exception.
Hi Frode,
the Problem is i have my own custompage with custom formular as ejscript
The user must be give an Email.
I sent the notification. All is ok but when the domain are not know. example: toto@toto.de the send Method give -1 at result in the debugger.
But the send() give void.
The Problem is then that the content from the mail are showing of my page and not the rest of my code.
The question is how can i know that the mail are be sending and go to the rest of my code.
Thanks