ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Using a batch file to create a hyperlinked png or jpg image.

(1/4) > >>

This may be answered somewhere but everything I have tried fails at the point of use.
I have a batch file that performs various functions and i the final steps creates a link to a page on a website that is output as a text file along with a image file named "invitation.png".
Once completed, I have to open Outlook, start a new email, paste in the 'invitation.png', right click it, choose add hyper-link, then paste in the hyper-link from the text file.
This works perfectly ... but is tedious when done often per day.
Being a big fan of automation and having a working batch file that already creates all the necessary parts, I am looking for a way to combine the final "done by hand" part.
But apparently automating the insertion of a hyper-link into an image file which is then sent via an email is beyond anything I can follow. I tried most methods I could come up with but  did not get any that worked.

Given that I have the necessary parts, is there a scripting maneuver to get this hyper-link embedded into the png file and put the whole thing into the body of an email ready to send? 

Too little info to go on, but I'll try anyway.

If Outlook is required, you better use PowerShell, which is more powerful and can access applications & servers installed on your system in ways batch scripts cannot even dream of.
But if that isn't the case, you could use batch script in combination with a command-line mailer (3rd party or what is included with Windows) and push out the messages that way. With batch scripts it is usually best to keep things as simple as possible.

There are even SMTP servers you run from the command line on your computer...but use those at your own peril. You don't want your IP address being blocked by organizations that patrol the internet for spammers.

Maintaining your own mail server is a job not for the faint of heart, because there are so many ways of doing it wrong. Better use the mail services provided by your ISP or mail host.
A command-line mailer can send mail through those services without problems, provided you use ports that aren't blocked. Most ISP's block port 25 by default to prevent unsanctioned SMTP traffic (a.k.a spam).

Find out how Outlook is sending your mail now (SMTP/IMAP/Exchange/whatever) and find a command-line mailer that can do the same. Use the settings from Outlook with the command-line mailer and you should be able to send mail just like Outlook does, only without Outlook. From here it should be relatively easy, as you already have the rest of the "building blocks".

I don't have Outlook but I would think it would be easier to put the image on a server then you would only need a line in the message body to call it, (IIRC), eg.

--- Code: Text ---<a href=URL><IMG=image URL></a>
This could then be used in a command file using the information from here:

The last section, Single command-line string for a message with subject and body, would create the email so all you'd need to do is hit send.

So goes the theory.

Only problem is if the image change for each email.

See here for attaching from the command line but I've got no idea what HTML/whatever you'd need in the body to create the URL link using an attachment.

Thanks shade.  Mailto is the function use to get outlook to open a new email.  It works very well.  But getting the image into the opened email is going to be either AHK or ???
I have looked ever where for a command to grab a file and put it in the mail.  It  is SO easy to do  copy and paste or any number of screen capture programs leave exactly what i need onthe windows clipboard where a paste command is all it takes.
This is a straight up Window setup MS Outlook and all.  I know what needs to be done but am short on the "how to do it" department. :(

Once I get the image into the email then i think i am in unknown territory needing to use VBA scripting to manipulate items in an email which will probably kill the whole thing.
Once upon a time, you could simply embed hyper-links in images anyway but the only ones that can do that now (as fas as  know) are "favicon.ico" files
Maybe there is a way I can copy the favico.ico file into the email but not sure it would even function as a web-link if done that way?  Never tried that.

This is one of those exercises in effort that probably are not worth anything other than to find out if it can be done?

Thanks 4wd!  You ALMOST got me there.  That link has a lot of the arcane wigged out architecture for it.
It is working now ALMOST.
the strctest sense of ot is this structure:

"C:\Program Files\Microsoft Office 15\root\office15\OUTLOOK.EXE"/c ipm.note /m "[email protected]&subject=test%20subject&body=test%20body" /a c:\wusa.txt

A few canges to some places got me very close this actuallty does work believe it or not.  the strikeout needs t be chaged out course
the subject etc easy to see how to edit
the body is the final hurdle as i want to put there the contents of the clipboard.  Atthe time this is run, the image is alrady held inthe clipboard and i normally chose paste to add it
so the final part "body=?" to copy contents of clipboard to body.  Then the coup de gras would the addition of the hyper-link.  If this works I think it would be a recipe for scriptng never before used for anything

I am barely runnig on just the memory of coffee from hours ago. so this may have to sleep for the night


[0] Message Index

[#] Next page

Go to full version