Send To/Mail Recipient from WSH - email

I am trying to implement in windows scripting host the same function as windows Send To/Mail Recipient does. Did not find anything usefull on google except steps to instantiate Outlook.Application and directly calling its methods.
I need to go the same path as windows do, as there is a mix of Outlook and Lotus Notes installed, I don't see it good to perform some sort of testing and deciding which object to talk to...
What I have found is that the actual work is done by sendmail.dll, there is a handler defined in registry under HKEY_CLASSES_ROOT\CLSID\{9E56BE60-C50F-11CF-9A2C-00A0C90A90CE}. I would like either to use this dll somehow or to simulate the same steps it does.
Thanks for your input.

I found one item on CodeProject from 2003 that might be relevant.

The contents of the sent to menu in Windows is a bunch of files (usually links) in the C:\Documents and Settings\username\SendTo folder. You need to add your script - or a link to it - there.
For your script you could check if certain registry keys exist to detect Outlook and Lotus Notes.
Or if you don't care if the message shows up in sent items, just use CDOSYS.NewMail to send the message directly to the SMTP-server.
CDOSYS documentation

Related

powershell - link to attached file in mail message

I can't find the solution for my problem. So, in my send-mailmessage html body is field that should be redirected to file which is included as attachment in message. How can I create hyperlink to that file in mail, when client opens it?
I don't know if you get my idea. In other words, in message I have attached file, and then there is field which should be a hyperlink to attached file. When client receives message he/she should press the link and then attached file opens.
I searched almost everything in everwhere but can't find a appropriate solution how to solve this.
This isn't really a PowerShell question, since this issue has nothing to do with the functionality of the Send-MailMessage cmdlet.
In any case, the reason you can't find a solution anywhere is that what you're trying to do is impossible. There is no way that a hyperlink in an e-mail message can point to a file attached to that message. Different mail clients on different operating systems store attachments in different locations. Even if you want to assume that all your recipients are running Outlook on Windows, there are different versions of both. Even if you know for a fact that all recipients are running a specific version of Outlook on a specific version of Windows, you're still out of luck. Outlook stores attachments in a subfolder in the Temporary Internet Files in the user's profile that has a randomly generated name. There's no way to inject code into a hyperlink in an email message, so without knowing the exact local file location, you can't link to it.
I suppose if you're really determined you could have the hyperlink point to a web page that runs some complex javascript code that tries to figure out where the attachment is stored, but that's a major undertaking, and would break if the recipient's default browser has javascript disabled.
Which begs the question, why exactly are you trying to do this? So that recipients can click once instead of having to double-click to open the attachment?
I have found that you can make a hyperlink point to a file share that you know the recipients have access to.
To do so:
Simply make each hyperlink point to the specific file and there you have it.
They have to have permissions to access that file share, or there is a much better way now that I haven't thought of.
Oh well, this works for me, for now.

Openoffice Writer macro that uploads current file to a web service on save

I want to know if this is doable and get some hints about how to achieve this.
I guess at least it would need a confirmation dialog to run the (possibly evil) macro.
I want to produce an OpenOffice document that will upload itself on save to a hardcoded URL.
Is it possible?
What are the rough steps to achieve this?
My guess is:
bind a macro to the save event
have that macro get the current file binary data
have it post this data to a URL
but before researching about how to do this I need to know if this can be done in the first place.
I don't believe you need a macro to do this, instead depending on your OS you can map a FTP or other type of protocol remotely.
For example in windows you can "Map" a FTP as a drive and this would do exactly the same thing as your describing, you open the file from the FTP and upon saving it will then be written to the remote server. FTP is just an example here, there are other platforms you can use.
If you are at all interested in this method then following the instructions below, otherwise disregard.
Mapping a Network Drive in Windows Vista and 7.
Click on Windows start orb and then click on "computer".
Click on map a network drive.
Map a network drive will then open a new dialog box where you can click "connect to a website"
Simply follow that easy to use wizard and click add a new network location (Choose a custom network location)
Type in your FTP address, including username and password.
Finally name your network location to whatever you want.
Just a suggestion, I really don't think you need any macro unless you plan on distributing these files to other people then yes, but they would need to install that macro/plugin on their open office since there is no way to encode the document itself with such features as far as I know.

How do browsers communicate with email programs?

I've searched around for a bit, but haven't been able to find anything useful on this.
How do browsers communicate with email programs, such as Thunderbird and Outlook (on the Mac, if that's relevant)?
By communicate, I mean the process it goes through to create a new email window with a designated to address, subject, body, through the mailto: link. How does the browser let the email program know what to put for each field? Using the command line (for Thunderbird, at least) didn't make much sense, as that opens a brand new instance of Thunderbird on the Mac.
I haven't found any sort of API for this, so if someone can point me in the right direction, that would be greatly appreciated. Thanks!
On windows, the browser use the "default" email client defined by the system.
It's stored in the Windows registry and define the command line to open the mail program. You can find more info and an exemple on the Microsoft website.
http://msdn.microsoft.com/en-us/library/windows/desktop/cc144109%28v=vs.85%29.aspx#sample_mail_program
If I look in my registry for thunderbird, It seems to execute:
"C:\Program Files\Mozilla Thunderbird\thunderbird.exe" -osint -compose "%1"
I have no idea how it works for the mac!
the additional information sent to the mail client is usually (from what i have seen) tacked onto the back of the mailto command.
in the following example, the client should automatically fill in the subject as 'greetings from stackoverflow'
mailto:hello#example.com?subject=greetings from stackoverflow
i have listed the other commands i know of below:
to edit subject: ?subject=
to edit cc: ?cc=
to edit bcc: ?bcc=
to edit body content: ?body=
these can also be used together by placing them after eachother and swapping the '?' for a '&', example
mailto:hello#example.com?subject=hello there&body=goodbye
this should create an email with the subject of 'hello there' and a body message of 'goodbye'
i hope this helps!
A very useful oldies that explains the surface called RCDefault
It shows you that the Finder or the Browser uses (can use) URLs to call other applications.
I am attaching the screenshot for the Mail application on OSX here:
The OS will then call this application with the URL (or file) and the application is supposed to understand how to open that URL.
The URL scheme for the mailto protocol for apple, is here
You should be able to find other schemes for the application you need to use.

Is it possible to record the open emails in Outlook 2010 with PowerShell so that they can be opened again later?

This question is very similar to https://stackoverflow.com/questions/6839516/outlook-2010-reopen-messages which was closed as not being a question.
I have a bad habit of keeping emails open in Outlook 2010 as a reminder of what needs to be done during the day since I am constantly interrupted. What I would like to do is use PowerShell to get a list of the open emails so that if I need to close Outlook I know what I was working on before.
I am not worried about Outlook crashing, Outlook normally reopens all of the emails I had been working on automatically; the use case I am dealing with is when I have to manually close Outlook for a patch or to address some other issue.
What I would like to do is query the running Outlook process and see what messages are open; opening a new Outlook process via COM won't work since it would have a different list of open messages.
Does anyone know of a way to do this in PowerShell? I can use another language if needed, but have been attempting to standardize on PowerShell where possible so that other people here can reuse any code I write.
One possibility I have considered is to launch Outlook via PowerShell so that I have a way to interact with the running process.
First of all, you need to get a reference to the running Outlook instance.
$outlook = [System.Runtime.InteropServices.Marshal]::GetActiveObject('Outlook.Application')
Using the application object you then
Iterate through the outlook.Inspectors collection
Ask each individual Inspector for its CurrentItem
Store whatever properties you need from this item (date? subject? entry id?)

how do I set a Thunderbird signature to use a dynamic url's html?

I want to use a dynamic email signature in Thunderbird, that is context aware (depends on date, events in db, etc.)
If I have a PHP that can generate the signature html (i.e. http://www.site.com/email_sign.php)
how do I force Thunderbird to use it?
(the only options I see are using static html (whether inline, of from a local system file).
any ideas?
You can use the Signature Switch add-on and a batch file calling wget to achieve what you want. I wrote a simple executable to replace the bat file; you can read about it (and download it if you want to) from http://www.else.co.nz/portfolio/020-code/dynamic-email-signatures
I doubt you can do this simply. Thunderbird does allow scripting via the creation of plugins but I wouldn't personally know how do do it or how easy it might be.
Best answer I can think of would be to set a scheduled task / cron job to download the php to a local file then follow the instructions in the knowledge base, namely:
You can use Thunderbird to create signature files, or you can use your operating system tools to create them—for example, a plain text editor.
Thunderbird does not provide any
special place to store signature
files. You could create a Signatures
directory in your profile to store
them, making them easy to back up
along with the rest of your profile.
Or you could store them somewhere
else.
To use a signature file, specify it in
Account Settings as the signature for
an identity. Check the box "Attach the
signature from a file instead" and
specify the signature file.
This will work unless Thunderbird caches the HTML internally, however I see no indication in the FAQ that this is the case.
For years I updated the signature for my email client manually – until I got fed up… That’s why I wrote a PHP script to create a randomized signature block automatically from an RSS feed! Check it out: https://github.com/birdy1976/signature :-D