web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Binesh Profile Picture
    7,885 on at

    Hello M.Zayed,


    You can not get the record after init, you have to first inter.

    See the bellow code

    CompanyInfo.GET;
    CompanyInfo.CALCFIELDS(Picture);
    IF CompanyInfo.Picture.HASVALUE THEN BEGIN
     CompanyLogo.INIT; 
     CompanyLogo.Blob := CompanyInfo.Picture;
     CompanyLogo.INSERT;
     FileLogo := FileManagement.BLOBExport(CompanyLogo,'Signature.jpg',FALSE);
    END;
    //Here CompanyLogo is a TempBlob Record variable

  • M.Zayed Profile Picture
    462 on at

    Sorry this didnot solve the problem

  • M.Zayed Profile Picture
    462 on at

    I Fix the Problem! My 'CompanyInfo' record was of type TEMP!!!!!!!   :D

  • Binesh Profile Picture
    7,885 on at

    Hello follow this link

    https://saurav-nav.blogspot.in/2015/08/nav-2015-use-email-with-company-logo.html

  • M.Zayed Profile Picture
    462 on at

    ok the Code is working fine when I send the Email to my mail.  But if I send the mail to someone else the Picture in the mail body wont be displayed!!  ---> The reason for that is coz the Pic is saved in Navision magic Path.

    Any idea how can i send this mail to someone else and still the Pic will be correctly displayed

  • Suggested answer
    Community Member Profile Picture
    on at

    [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

  • M.Zayed Profile Picture
    462 on at

    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

  • Community Member Profile Picture
    on at

    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

  • Suggested answer
    Alexander Ermakov Profile Picture
    28,096 on at

    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

    [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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans