Publicaciones etiquetadas ‘Mail’

Error 0x80040211 () en envío mails

1 Estrella2 Estrella3 Estrella4 Estrella5 Estrella (1 votos, promedio: 3,00 de 5)
Cargando…
Escrito por René Roca el . Posteado en Consultoria, Tecnica, X++

Cuando trabajamos con varios AOS en Dynamics AX 2012, y utilizamos el envío de mails, nos podemos encontrar en la situación que desde un AOS nos funcione el envío perfectamente, pero desde otro AOS nos muestre el siguiente mensaje de error:

error_mail

Este error se produce, porque Dynamics Ax guarda el password del usuario de correo electrónico por AOS, si  vemos el método password de la tabla SysEmailParameters podemos ver como para recuperar el password busca por ID de AOS en la tabla SysEmailSMTPPassword

static SMTPPassword password()
{
    CryptoBlob cryptoBlob = connull();
    SysEmailSMTPPassword SMTPPassword;
 
    AOSId AOSId;
    AOSInstanceId AOSInstanceId;
 
    ;
    [AOSId,AOSInstanceId] = SysEmailSMTPPassword::currentAOSInstance();
 
    SMTPPassword = SysEmailSMTPPassword::find(AOSId,AOSInstanceId);
 
    if (SMTPPassword.RecId != 0)
        cryptoBlob = SMTPPassword.Password;
 
    if (cryptoBlob != connull())
        return cryptoblob2str(WinapiServer::cryptUnProtectData(cryptoBlob));
    else
        return '';
}

Si examinamos la tabla SysEmailSMTPPassword, tendríamos que tener una entrada para cada AOS, para ello tendremos que informar la contraseña en los parámetros de correo electrónico conectandonos a cada uno de los AOS que tenga nuestra instalación.
Si tenéis alguna duda de como conectaros a un AOS concreto, podemos ver como se hace en el siguiente artículo.

Envio Mail mediante X++

1 Estrella2 Estrella3 Estrella4 Estrella5 Estrella (Sin calificar)
Cargando…
Escrito por René Roca el . Posteado en X++

A continuación os dejo un código para poder enviar correos electrónicos mediante Dynamics Ax 2009, espero que os sirva de ayuda 😉

En caso que os dé un error al enviar el mail, podéis consultar la siguiente lista de errores, para detectar que está pasando

SysEmailParameters 	sysEmailParameters = SysEmailParameters::find();
InteropPermission 	interopPermission;
SysMailer          	sysMailer;
;
 
//Inicialización de los parámetros de correo electrónico.
interopPermission = new InteropPermission(InteropKind::ComInterop);
interopPermission.assert();
sysMailer = new SysMailer();
 
if(sysEmailParameters.smtpRelayServerName)
{
	sysMailer.SMTPRelayServer(sysEmailParameters.smtpRelayServerName,
	sysEmailParameters.smtpPortNumber,
	sysEmailParameters.smtpUserName,
	SysEmailParameters::password(),
	sysEmailParameters.ntlm);
}
else
{
	sysMailer.SMTPRelayServer(sysEmailParameters.smtpServerIPAddress,
	sysEmailParameters.smtpPortNumber,
	sysEmailParameters.smtpUserName,
	SysEmailParameters::password(),
	sysEmailParameters.ntlm);
}
 
//Montamos el Mail
sysMailer.htmlBody("Mensaje de prueba :)");
sysMailer.subject("Test 1");
sysMailer.fromAddress("dirección mail origen");
sysMailer.tos().appendAddress("dirección mail destino");
 
//Documento Adjunto
sysMailer.attachments().add("Ruta y nombre dle fichero adjunto");
sysMailer.sendMail();

Errores CDO.Message (Envio Mail)

1 Estrella2 Estrella3 Estrella4 Estrella5 Estrella (Sin calificar)
Cargando…
Escrito por René Roca el . Posteado en X++

Cuando utilizamos Dynamics Ax para enviar mails, en algunas ocasiones, nos podemos encontrar un mensaje de error como el siguiente:

Method ‘send’ in COM object of class ‘CDO.Message’ returned error code 0x80040211

Para poder interpretar que significa este código de error, a continuación os dejamos una lista con los códigos de error y su descripción para poder entender un poco más estos mensajes crípticos.

Value Remarks
0x80040201 Exception %1 was generated at address %2.
0x80040202 No data source has been opened for the object.
0x80040203 The object does not support this type of data source.
0x80040204 The object does not support the requested property name or namespace.
0x80040205 The object does not support the requested property.
0x80040206 The object is not active.
It may have been deleted or it may not have been opened.
0x80040207 The object does not support storing persistent state information for objects.
0x80040208 The requested property or feature, while supported, is not available at this time or in this context.
0x80040209 No default drop directory has been configured for this server.
0x8004020A The SMTP server name is required, and was not found in the configuration source.
0x8004020B The NNTP server name is required, and was not found in the configuration source.
0x8004020C At least one recipient is required, but none were found.
0x8004020D At least one of the From or Sender fields is required, and neither was found.
0x8004020E The server rejected the sender address. The server response was: %1
0x8004020F The server rejected one or more recipient addresses. The server response was: %1
0x80040210 The message could not be posted to the NNTP server. The transport error code was %2. The server response was %1
0x80040211 The message could not be sent to the SMTP server.
The transport error code was %2. The server response was %1
0x80040212 The transport lost its connection to the server.
0x80040213 The transport failed to connect to the server.
0x80040214 The Subject, From, and Newsgroup fields are all required, and one or more was not found.
0x80040215 The server rejected the logon attempt due to authentication failure. The server response was: %1
0x80040216 The content type was not valid in this context. For example, the root of an MHTML message must be an HTML document.
0x80040217 The transport was unable to log on to the server.
0x80040218 The requested resource could not be found. The server response was: %1.
0x80040219 Access to the requested resource is denied. The server response was: %1.
0x8004021A The HTTP request failed.  The server response was: %1.
0x8004021B This is a multipart body part. It has no content other than the body parts contained within it.
0x8004021C Multipart body parts must be encoded as 7bit, 8bit, or binary.
0x8004021E The requested property was not found.
0x80040220 The “SendUsing” configuration value is invalid.
0x80040221 The “PostUsing” configuration value is invalid.
0x80040222 The pickup directory path is required and was not specified.
0x80040223 One or more messages could not be deleted.
0x80040227 The property is read-only.
0x80040228 The property cannot be deleted.
0x80040229 Data  written to the object are inconsistent or invalid.
x8004022A The requested property is not in the mail header namespace.
0x8004022B The requested character set is not installed on the computer.
0x8004022C The ADO stream has not been opened.
0x8004022D The content properties are missing.
0x8004022E Content properties XML must be encoded using UTF-8.
0x8004022F Failed to parse content properties XML.
0x80040230 Failed to convert a property from XML to a requested type.
0x80040231 No directories were specified for resolution.
0x80040232 Failed to resolve against one or more of the specified directories.
0x80040233 Could not find the Sender’s mailbox.
0x80040234 Binding to self is not allowed.
0x80044000 The first argument is invalid.
0x80044001 The second argument is invalid.
0x80044002 The third argument is invalid.
0x80044003 The fourth argument is invalid.
0x80044004 The fifth argument is invalid.
0x800CCE05 The requested body part was not found in this message.
0x800CCE1D The content encoding type is invalid.