Delphi - Using resource in Email rather than image - email

In Delphi, I create emails in HTML using the following code to display a signature in the message:
cMsg:= cMsg + ' <img src="BarrysSignature.jpg" '>
Which means I need to have the .jpg available in the current directory (and distribute it with the executable).
I also use these same signature .jpg files elsewhere in my program, but I've loaded them as resources. What would be better in the emails is if I used the resource for the signature in the email, rather than the external .jpg picture.
I've tried a few ways of doing this but can't get it working. Any thoughts, please?

Similar to #Dmitry's answer, in Indy you would also need to attach the image data to an email (the TIdMessage component), assign the attachment's Content-ID header (the TIdMessagePart.ContentID property), and then refer to that ID in the HTML using a cid: URL where needed.
Refer to these blog articles on Indy's website for how to do this:
HTML Messages
New HTML Message Builder class
I do want to mention one thing, though. Where the articles talk about using TIdAttachmentFile for attachments, you actually don't need to save your image resource to a temporary file at all in this situation. You can alternatively derive your own class from TIdAttachment (let's call it TIdAttachmentResource), and have it override the virtual OpenLoadStream() and CloseLoadStream() methods to return/free a TResourceStream to your resource data, respectively (see the source codes for TIdAttachmentFile and TIdAttachmentMemory for examples). Then you can simply add TIdAttachmentResource objects to the TIdMessage.MessageParts collection as needed, and Indy will be able to encode the email using the image resource directly, no file needed.

In Outlook, you will need to extract the resource to a temporary file, add the image as an attachment, set its PR_ATTACH_CONTENT_ID MAPI property, delete the file. Your HTML body would need to reference the image by its content-id, e.g. <img src="cid:xyz">, where "xyz" is the value of the PR_ATTACH_CONTENT_ID property.
See Including Pictures in an Outlook Email

Related

LabDaq - sending attachment

I would like to attach a PDF file as the "result" for a LabDaq test and have it sent out through all the HL7 interfaces. The PDF file is not generated by LabDaq but rather added as an attachment. We see a way to select to have all attachments forwarded. However, we don't want to make a universal change for all attachments but rather a specific change for select attachments. For reference, the attachments are reference lab results.
You'll need to use the Mirth (Nextgen) Connect's Attachment Handler.
There's an overview on how to use it on the User Guide or on this blog post https://kailo.tech/health-it/mirth-connect-bits/mirth-connect-attachment-handler/
The blog post should explain how you can read a file and use the base64 string on an HL7 message.

Outlook Show Email Images to User

I'm trying to send mails to some users which are basically built over images. How can I get those images to download by default in the users' (outlook) mailbox?
I did try encoding the image in base64 and sending it, not as a hosted image but embedded in email-html. But that too, did not work :( (I was SO sure that it would)
The client (organization) is well aware of this (that we'll be exchanging mails). Is there any setting that can be tweaked in the admin panel of MSExchange or o365 which can allow this?
Users have to have that set in their preferences. You cannot make it automatically do it as an email sender due to SPAM senders and security reasons.
Outlook allows adding hidden attachments, you may refer mention they in the message body (embedded images). In the message body you may see the following tags:
<img src="cid:some-image-cid" alt="img" />
The "cid:" prefix means that name refers to the attached image with the specified content ID.
Attachment attachment = newMail.Attachments.Add(
#"E:\Pictures\image001.jpg",
OlAttachmentType.olEmbeddeditem, null, "Some image display name");
string imageCid = "image001.jpg#123";
attachment.PropertyAccessor.SetProperty(
"http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);
String.Format("<body><img src=\"cid:{0}\"></body>", imageCid);

File Upload: File Upload URL not provided

I've been trying to get file uploads to work, following the instructions for both Dropbox and S3 but each time I just get this message:
File Upload URL not provided
It doesn't seem to be making any calls to the server. I've found this mention of a bug around file uploads:
https://github.com/formio/ngFormio/issues/322
But I suspect that applies if you're hosting it yourself. I'm using the cloud version.
I've configured it with e.g. the S3 bucket's URL, authentication etc.
What does this error actually mean?
Update: here's the syntax I'm using:
<formio form="https://formview.io/#/xxxxxxxxxxxxxxxxxxx/applicationform" url="'https://formview.io/#/xxxxxxxxxxxxxxxxxxx/applicationform'"></formio>
Thanks
In order to make the uploads work, you need to provide the URL of your form, which is used to generate the upload token to upload the files to the 3rd party providers. This can be done in one of two ways.
<formio src="'https://examples.form.io/example'"></formio>
You would use above if you wish to render the form from the JSON REST API of the form. In many cases, you may wish to provide the actual form object (which I suspect is what you are doing) like so.
<formio form="{...}"></formio>
This works fine for rendering the form, but it does not provide the URL context for file uploads. For this reason, we have the url parameter which you can include along with your form object for file uploads to work.
<formio form="{...}" url="'https://examples.form.io/example'"></formio>
Providing the url this way is passive. The form will not try to submit to that url, but rather just use it as the url configuration for file uploads.

Retrieve and display inline images from email when encoded as a CID with Ruby on Rails

I'm using Viewpoint to retrieve email from an Exchange server for creation of objects in a Ruby on Rails app.
I'm able to see that an image has been included, inline, in the body of an email, like so:
<img src=\"cid:94C552FB-8474-437C-AB44-DDF809047AB9\" type=\"image/png\">
And I can see an attachments node in the item blob, too:
:attachments=>{
:file_attachment=>{
:content_type=>{
:text=>"image/png"
},
:content_id=>{
:text=>"94C552FB-8474-437C-AB44-DDF809047AB9"
},
:attachment_id=>{
:id=>"AAMkAGEzNmExNzEzLTcxMjEtNDM5YS04NmE0LWE0NWU3MWZiMjEwNgBGAAAAAAB4VZcbdHrATrbGrKL0ANCfBwCjSVkOjPEtQoJN3xOKeIYJAAzyZ5e9AACjSVkOjPEtQoJN3xOKeIYJAA25w05NAAABEgAQAK9ad+6BP7VHru83AO7CTrU="
},
:name=>{
:text=>"Hollowbody 2.png"
}
}
}
My question is, how do I turn any of this into a URL suitable for use as the src of an img tag? I've seen answers like this one, but they appear to have special privileges in that
They're running in C#, which has special understanding of Exchange and the way it handles resource (I assume)
They appear to be running on the same server as Exchange, and have access to the same tmp directory where attachments are held.
If you're on another machine in another language, how do you get to these images? I know it's possible, since there are email clients on everything from mobile phones to refrigerators that can receive emails from Exchange/Outlook and render the imageā€¦

Fetching Contact image from SugarCRM

I'm trying to integrate my rails app with SugarCRM. Is it possible to fetch the Contact picture from SugarCRM using REST API? Please let me know.
To get the profile image for a user do the following:
Call the login method through REST
Call the get_entry_list method through REST, with the following parameters:
Module: Users
Query: users.user_name = 'xxxx'
Select_fields: picture
The response contains the filename for the profile image, which is stored in /uploads.
However, it is not possible to view the image in that folder due to .htaccess restrictions for security reasons, but other options exist:
Extend the REST API with a method to serve profile images (similar to get_document_revision)
Login on the server from your rails app and get the image
Create a simple entrypoint+module in SugarCRM, which can show the picture
Remove the .htaccess restiction for images (if it doesn't create a security risk in your setup)
In such scenario, I faced a problem where the upload folder stores file with name of the record id, i.e the GUID without file extension.
So to cop up with this I did write a function to copy the file at same hierarchy but with its extension.
Example:
A png extension file at upload folder with name say, '32sdft-tg35f-Tuhis-675rtyf-77666-46dgc' will end up as, '32sdft-tg35f-Tuhis-675rtyf-77666-46dgc.png'
Now only the path will be require to render the image.
Rest all things as applicable as suggested by our friend, Kare !!