Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Insert Company logo in Navision Mail body

(0) ShareShare
ReportReport
Posted on by 462

Can anyone please look at the next code and tell me what Iam doing wrong. I want to add our company logo to the mail.

Code:

----------------------------------------------

CompanyInfo.CALCFIELDS(Picture);
IF CompanyInfo.Picture.HASVALUE THEN BEGIN
CompanyLogo.INIT;
CompanyLogo.GET;
CompanyLogo.Blob := CompanyInfo.Picture;
CompanyLogo.INSERT;
FileLogo := FileManagement.BLOBExport(CompanyLogo,'Signature.jpg',FALSE);
END;


pBodyBlob.Blob.CREATEOUTSTREAM(BodyStream);
BodyStream.WRITETEXT(STRSUBSTNO('%1 ',Text_Dear) + pCustomer.Name);
BodyStream.WRITETEXT('<br><br>');
BodyStream.WRITETEXT(STRSUBSTNO('%1 ',Text_Body));
BodyStream.WRITETEXT('<br><br>');
BodyStream.WRITETEXT(STRSUBSTNO('%1',Test_Regards));
BodyStream.WRITETEXT('<br>');
BodyStream.WRITETEXT('Mohamed Zayed');
BodyStream.WRITETEXT('<br><br>');
BodyStream.WRITETEXT('BA.Service GmbH');
BodyStream.WRITETEXT('<br><br>');
BodyStream.WRITETEXT('<br><br>');
BodyStream.WRITETEXT('<br><br>');
BodyStream.WRITETEXT('<br><br>');
BodyStream.WRITETEXT('<IMG style='HEIGHT: 153px; WIDTH: 445px' src='file:///'+ FileLogo +'''+ 'width=100 height=100>');   // here is the problem

BodyStream.WRITETEXT('<br><br>');
BodyStream.WRITETEXT('<br><br>');

BodyStream.WRITETEXT(STRSUBSTNO('%1',Text_SystemMail));

--------------------------------------------------

Results:

Image cant be displayed ---> Donot know why

Mail-Error.png

*This post is locked for comments

  • Verified answer
    M.Zayed Profile Picture
    462 on at
    RE: Insert Company logo in Navision Mail body

    Hi Mads,

    This is the solution:

    saurav-nav.blogspot.de/.../microsoft-dynamics-nav-2017-email-from_21.html

  • MadsG Profile Picture
    on at
    RE: Insert Company logo in Navision Mail body

    M.Zayed did you find a solution to this problem?

    Thanks.

     

  • M.Zayed Profile Picture
    462 on at
    RE: Insert Company logo in Navision Mail body

    Thanks  Dennis,

    I am also trying to find a solution for the problem till now. I will post the solution once i have it, hope i will have it soon :).

    Regards,

    Zayed

  • Community Member Profile Picture
    on at
    RE: Insert Company logo in Navision Mail body

    Hey again,

    i have take a look at CU400. At the create method is a call "IF HtmlFormatted THEN Mail.ConvertBase64ImagesToContentId;". It returns a boolean.

    I tried to use this method but it returnes always 'false'. 

    This method is a member of "Microsoft.Dynamics.Nav.SMTP.SmtpMessage.'Microsoft.Dynamics.Nav.SMTP, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'". I can't find Plain Text for this DotNet, so i can't check what's going on.

    I think the idea behind is to add images as Base64String and convert them to ContentId but it looks like it doesnt work.

  • M.Zayed Profile Picture
    462 on at
    RE: Insert Company logo in Navision Mail body

    Hi Alexander,

    This link is not 100% helpful. The image in this link would be exported and saved on the server. I applied the solution in the link but as I said before when I send the mail to someone else he won't see the logo.

    The reason behind this is that the Logo is export into some magic path on the server and if I send it to my self I will see it! otherwise all other user cannot see it.

    Regards,

    Zayed

  • Community Member Profile Picture
    on at
    RE: Insert Company logo in Navision Mail body

    [quote user="Alexander Ermakov"]

    As Binesh suggested, have you looked at community.dynamics.com/.../nav-2015-use-email-with-company-logo-and-url ?

    [/quote]

    This works only if you receive the email at the same computer from which you send it AND only if the email programm have access to your local drive.

    But ok, i tested it:

    I downloaded the Codeunit and send an email...
    now i received this email and it looks good in my outlook

    Now i checked the SAME email at https://outlook.office365.com

    email-in-webclient.png

    it doesn't work

    i checked the sourcecode:
    <img style="HEIGHT: 153px; WIDTH: 445px" src="file:///C:\Users\dennis.reinecke\AppData\Local\Temp\Microsoft Dynamics NAV\10252\{246EB00A-65F9-4087-8AF7-415E88FA6EDA}.jpg" width="100" height="100">
    this is why it works well at the sending computer.

    This is logical because the browser can't access this path at your computer.


    Best
    Dennis

  • Suggested answer
    Alexander Ermakov Profile Picture
    28,094 on at
    RE: Insert Company logo in Navision Mail body

    As Binesh suggested, have you looked at community.dynamics.com/.../nav-2015-use-email-with-company-logo-and-url ?

  • Community Member Profile Picture
    on at
    RE: Insert Company logo in Navision Mail body

    Hey,

    first, im sorry.

    I checked and tried some stuff now. It looks like Outlook dont like Base64 images. At our MAC it looks fine.

    found this: https://www.campaignmonitor.com/blog/email-marketing/2013/02/embedded-images-in-html-email/

    I tried to use "Customer Word Reports" with an Image and send it as Email Body, but this doesnt work. May should try a RDLC Report as email body, but i think it wouldn't work too.


    If you send an image with outlook it looks like "src="cid:image001.png@01D2EB4D.6D41E590"" this is a link to an image which is defined as base64 in the Email Header. It looks like this:

    https://stackoverflow.com/questions/4312687/how-to-embed-images-in-email?answertab=votes#tab-top

    Best

    Dennis

  • M.Zayed Profile Picture
    462 on at
    RE: Insert Company logo in Navision Mail body

    Hi Dennis,

    Are you sure that I can send the image as BASE64 string  in Navision?

    I made the follwoing but its not working:

    1778.Untitled.png

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Insert Company logo in Navision Mail body

    [quote user="M.Zayed"]

    <IMG style='HEIGHT: 153px; WIDTH: 445px' src='file:///'+ FileLogo +'''+ 'width=100 height=100>

    [/quote]

    Do you know what this do? It's a Link to your Filesystem, just try it out in your browser like 'file://c:/'. It will open your C: directory

    To fix this:

    You can use a public URL where u can find the CompanyLogo (It's a bad idea if you create it on the fly)

    or you send the image as BASE64 string - see: https://en.wikipedia.org/wiki/Data_URI_scheme#HTML

    Best

    Dennis

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans