Create a test script to send an email:
using com.shephertz.app42.paas.sdk.csharp;
using com.shephertz.app42.paas.sdk.csharp.email;
using UnityEngine;
public class enviaEmail : MonoBehaviour
{
string sendSubject = "Here we are sending an Email";
string sendMsg = "Body of message";
string emailHost = "smtp.faciltecnologias.com.br";
int emailPort = 587;
string emailId = "financeiro@faciltecnologias.com.br";
string password = "ale240471";
bool isSSL = true;
public void enviarEmail()
{
if (SingletonController.user != null)
{
EmailService emailService = SingletonController.serviceAPI.BuildEmailService();
emailService.CreateMailConfiguration(emailHost, emailPort, emailId, password, isSSL, new UnityCallBack());
emailService.SendMail(SingletonController.user.email, sendSubject, sendMsg, emailId, EmailMIME.PLAIN_TEXT_MIME_TYPE, new UnityCallBack());
}
else
{
print("Usuário inexistente!");
}
}
class UnityCallBack : App42CallBack
{
public void OnSuccess(object response)
{
Email email = (Email)response;
string jsonResponse = email.ToString();
print(jsonResponse);
}
public void OnException(System.Exception e)
{
App42Log.Console("Exception : " + e);
Debug.Log("Exception : " + e);
}
}
}
However two messages are received: the first one informs about the ok setting for the email, but the sending of the email fails informing that the email already exists. Where does he exist? USER's email is another.
Messages Received on Unity3D Console:
{"app42":{"response":{"success":"true","email":{"from":"financeiro@faciltecnologias.com.br","to":"vendas@faciltecnologias.com.br","subject":"Here we are sending an Email","body":"Body of message"}}}}
Exception : com.shephertz.app42.paas.sdk.csharp.App42BadParameterException: {"httpErrorCode":"400", "appErrorCode":"2301", "message":"Bad Request", "details":"The request parameters are invalid. Email id 'financeiro@faciltecnologias.com.br' already exists."}