Saturday, January 15, 2011

Emailing embedded images from Dynamics AX

When I first tried sending an email with images it showed the standard image not found image from Microsoft internet exploder.


This was the image in all the emails sent by AX.

We are using AX 4.0 SP2 with hotfixes applied....I began to dig...I found that the image path is replaced with cid:1 because it is an embedded resource in the email.....then discovered two things needed to be true:

  • Any images that you include in an email must exist in the directory specified at SysEmailParameters.AttachmentPath.
  • You must change the code if the location is a shared directory starting with two forward slashes //
The code checking that the image exists in the correct directory has a BUG and well it is overly complex (KISS).  Just replace this method below...

public static boolean isFromAttachmentsFolder(str _pathName)
{
    str attachmentsFolder;
    str pathName;
    ;
    // Fix embedding images in emails
    attachmentsFolder = SysEmailParameters::find().AttachmentsPath;
    pathName = _pathName;

    attachmentsFolder = Global::strReplace(attachmentsFolder,'\\','/');
    pathName = Global::strReplace(pathName,'\\','/');

    // Fix embedding images in emails
    return Global::strStartsWith(strupr(pathName), strupr(attachmentsFolder));
}

No comments:

Post a Comment