how to paste a copied image in send email

Hello everyone,

I am trying to automate a process to send email with a message. i am using Email- POP3/SMTP business object.
i wanted to copy a screenshot and send it in message using paste option ( control + v)
can you tell me how to paste the copied image in message. i tried with "^v" as body text input, but its taking as a text input but not paste.

can someone help me in this regard.

Thank you.
Susheel
 

VJR

Well-Known Member
Hi Susheel,

Make sure to enable BodyIsHTML.

First you will need to actually attach the image to the email as an attachment.
Assuming [colMyImage.ImagePath] is the variable that has your image...
Try this in the Body and share what happens. Later on once it works you can remove the wordings "Embedded Picture."

"<html><body>Embedded <img src=""cid:" & [colMyImage.ImagePath] & """ > picture.</body></html>"
 

VJR

Well-Known Member
The Email object takes collection for attachments.
But since you are copying the image you might have to make use of the Clipboard methods of the 'Utility - Environment' VBO to store the image in the collection with data type as Image. I suggest first try with a physical file path and then try working the logic using a copied image.
 
Last edited:
Hi VJ,

thanks a lot for your explanation.
i have tried using the attachments in the email. it is working good.
however, I'd like to know if i can send image directly in the message body without attaching it.
coz, i am taking a screenshot of a web page , copying it in paint and saving that image in a folder and then i am taking that path to the attachment for sending a mail.
i wanted to skip the step of saving image in paint and instead of that i want to send directly in the message with paste (Ctrl + v) option.

kindly let me know if you have any idea in it.

best regards,
Susheel
 

VJR

Well-Known Member
Hi Susheel,

The approach that I mentioned above is not for sending the image as an attachment.
For embedding an image in an html body first you need to attach the file and then use the cid parameter (content id) of the html img tag.
 

VJR

Well-Known Member
In the second post I mentioned that since you have the image copied in Clipboard you might have to use the environment object to save it from the clipboard to an image type collection field because the attachment parameter of email object only accepts a collection. So I am suggesting here to first try with an actual file path for the collection instead of accessing the clipboard.
 
Hi VJ,

could you explain me how can i attach image in the send message with out path .
i am trying to change the collection field type to image in collection properties of business object. however i am getting error as following

"Internal : Collection fields are defined but cannot be matched to the incoming collection - The collection definition does not contain the field Image"

do you have any ideas to resolve it.

thank you
 

VJR

Well-Known Member
Hi Susheel,

The Attachments collection of the Send Message action of the Email object only accepts a path so it is not allowing to change it to an Image data type.
1524054848912.png


On the the other hand, after I provided you the HTML code to embed the image, you made a mention that you do not want to make use of the Paint application to save the image as a physical path. The 'Send Message' action of the Email POP3/SMTP object is written in C# and you can see the attachment code. Some programming languages have a position parameter if set as 0 then the attachment becomes hidden and still continue with the embed code. So you might want to explore that and if you find relevant code then can make a copy of the existing Send Message action and create one of your own.

However, if you only want to skip the Paint part, one could write a new object Action say 'SaveClipboardImageOnPath' by adding a Code stage which will save that image from the Clipboard to a physical path. Once you have the path you can pass it as a parameter to the Attachments collection and then pass it in the HTML cid. Let me know if you want to explore this option.


One thing I forgot to mention about the html code (where you still need to attach the file):
"<html><body>Embedded <img src=""cid:" & [colMyImage.ImagePath] & """ > picture.</body></html>"
If you use this code and if the recipient is not able to see the image, then instead of the full path in the cid parameter you just need to give only the file name with extension (eg; Image1.jpg) and it will automatically take the cid of the file.
 
Hi VJR,

Thanks a lot for your detailed explanation :) i will try your solution.

could you tell me how to shift from one window to another active window and take a screenshot of the required window .
i am not able to select a required window.
 

VJR

Well-Known Member
Hi Susheel,

Okay good to know you will be trying out the options. If you choose to go by the SaveClipboardImageOnPath approach then let me know and I could assist you on how could that be done.

More details would be required to know what the windows are about, are they desktop application or web, how have they been opened, but in general you could spy a window using the Application Modeller based on the Window Title parameter and take the required course of action. Or if Sendkeys Alt + Tab works for you then you could use that.
 
Hi VJ,

I will use SaveClipboardImageOnPath approach. i let you know if i face some issues with it.

For the same screenshot application. i am trying to take a screenshot of a webpage using snipping tool of windows. for that purpose, first i need to open the webpage in browser window and then open snipping tool window, and again go to webpage window to crop the required portion of the webpage. so can you assist me how to shift between windows, or which would be appropriate spying mode to activate window in this scenario ?

Thank you :)
 

VJR

Well-Known Member
Hi Susheel,

A Windows application has an Activate action in the dropdown of the Navigate stage. So you can use it to have the focus on the Snipping tool. But I've never seen it for a Web application. So you will probably need to spy the browser window (perhaps from another object outside of your existing one) and then find a way to focus on it either by the process name or the window title. It's surely going to get trickier down the lane as you get going further by capturing a screenshot using the Snipping Tool. But if you achieve it we all will have a new way from what you are doing. I still recommend capturing the screenshot using the Code stage that I had suggested you earlier here. Perhaps you can play around with it to modify the co-ordinates if you do not want to capture the entire screen.
 

Abhinav2020

New Member
Hi Susheel,

The Attachments collection of the Send Message action of the Email object only accepts a path so it is not allowing to change it to an Image data type.
View attachment 596


On the the other hand, after I provided you the HTML code to embed the image, you made a mention that you do not want to make use of the Paint application to save the image as a physical path. The 'Send Message' action of the Email POP3/SMTP object is written in C# and you can see the attachment code. Some programming languages have a position parameter if set as 0 then the attachment becomes hidden and still continue with the embed code. So you might want to explore that and if you find relevant code then can make a copy of the existing Send Message action and create one of your own.

However, if you only want to skip the Paint part, one could write a new object Action say 'SaveClipboardImageOnPath' by adding a Code stage which will save that image from the Clipboard to a physical path. Once you have the path you can pass it as a parameter to the Attachments collection and then pass it in the HTML cid. Let me know if you want to explore this option.


One thing I forgot to mention about the html code (where you still need to attach the file):
"<html><body>Embedded <img src=""cid:" & [colMyImage.ImagePath] & """ > picture.</body></html>"
If you use this code and if the recipient is not able to see the image, then instead of the full path in the cid parameter you just need to give only the file name with extension (eg; Image1.jpg) and it will automatically take the cid of the file.
hi

I have taken the screen shot and save it to particular path , but when I provide the path as you suggested in HTML code , not able to view screen shot when other user try to see the mail . Could you please suggest where I missed something ?
 

VJR

Well-Known Member
hi

I have taken the screen shot and save it to particular path , but when I provide the path as you suggested in HTML code , not able to view screen shot when other user try to see the mail . Could you please suggest where I missed something ?
Hi Abhinav2020,

As suggested above you will also need to attach the image to the email. Have you done that? Then in the html while giving the cid pass only the file name with extension.
 

RMB

New Member
The Email object takes collection for attachments.
But since you are copying the image you might have to make use of the Clipboard methods of the 'Utility - Environment' VBO to store the image in the collection with data type as Image. I suggest first try with a physical file path and then try working the logic using a copied image.
The 'Utility-Environment' VBO has a method of GetClipBoard but it always gives TEXT as output and we cant change it either to 'image' then how do we capture the image that is in clip board to collection variable?
Also, anyway that we can send CTRL+V using SGK?
 

BotBuilder1124

New Member
Hi RMB,

That's an old post you are referring to.
You can find some new posts below that will help you achieve the same.

- Post #14: Saving an image from a Clipboard to an Image file
- Post #5: Store an Image file from a path into an Image data item
- Post #6: Image in mail body
Hi VJR,

I have an image saved locally which I am trying to embed in an email to be sent out. I have attached the image to the email via a collection containing the path, however I don't know where/how to find the CID of the image to go into the body of the email. Can you clarify how to get that?
 
Top