We help IT Professionals succeed at work.

Client side mailing with attachments

philkeene asked
Last Modified: 2012-06-27

I have a requirement for a link or button on an intranet page that opens a new e-mail with attachments already on there, so that the user can edit the mail and choose who to send it to etc. The users use outlook 2003, 2007 and 2010 (although 2003 is almost non-existant on the network now) for their e-mails, and mainly internet explorer 6, 7 and 8 for internet browsing. (There may be one or two with Firefox, but we can almost ignore it if there is a good solution that is only compatibly with IE.)

I do not want to use server side mailing. I want to use the user's mail client, and the attachments must be attached automatically. The attachments will be selected by the client through a web interface from a network shared folder that is available to the webserver and the clients.

I have looked into the <a href="mailto:..."> approach, but attachments are not supported on this.

Does anyone have any good ideas for how to do this? If necessary I can enforce installation of programs on all the user's client PCs, but if possible I would like to avoid this.


Watch Question

You are better off sending a link to a document.  This will also prevent everyone's mailbox from becoming bloated with the same document.  If this is an intranet, you almost certainly want to link to a document so that if the document ever changes, nobody is using an outdated version.
And sorry, wasn't trying to jump around the question.  There is no way to do what you are wanting via the client.  You must use server side technology to attach documents to a message.
Unlock this solution and get a sample of our free trial.
(No credit card required)

There is no way to do what you are wanting via the client.
@Designbyonyx: With IE you never know what strange stuff it is capable of ;)


Designbyonyx, thanks for your replies, the link idea unfortunately won't work since the documents sometimes need to be sent to recipients outside of the network.
Onthrax, your solution looks fantastic, however I'm not too sure where to start with creating the ActiveX script. I understand the code you have posted, but what do I do with it? How can I add it to the web page? Sorry for my lack of knowledge on this subject.

It's just javascript. Simply put it inside a function within <script></script> tags and it'll work just fine :)


And that's why I apologised for my lack of knowledge... I can't believe that I didn't spot that... thanks for your help on this.
@Onthrax - leave it to IE to do all sorts of cool stuff, EXCEPT for rendering html ;)

Amidst my curiosity, I found this:


Also, you could create a form where a user can input the "from" and "to" address, and you can send the email from your server-side code.  I know you have probably considered that... but throwing it out there to see what your objections are.


Designbyonyx, I'm with you on the rendering issues, but unfortunately IE is the most popular evil among browsers. I have decided against the server-side e-mailing because I need the users to have the maximum flexibility when they are sending the e-mails. As for the C#/VB.net solution, would that provide a solution in IE and FF. I could be being dumb, but I don't get how I would use that on a web page.
Onthrax, your code (with a few minor amendments) works great in IE, and as you said doesn't work in FF. This is a great solution. If I can come up with a solution that works in FF as well then it will be even better, but if not I think I will be able to get away with it. I have attached your code with the amendments I made just for completeness.

var outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
var mailItem = mailFolder.Items.add('IPM.Note.FormA');
mailItem.Subject="CUSTOMER SERVICE";
mailItem.To = "test@test.com";
mailItem.HTMLBody = "SOME HTML CODE";
mailItem.Attachments.Add ("C:\\test\\test.txt");
mailItem.display (0);
E-mail opened!

Open in new window

Glad you got it working :)

@Designbyonyx: Just to clarify. I hate IE. Rendering is crap, css support is crap etc. Although IE9 does sound promising.. we'll see.
@Onthrax - if you are using this website... you better hate IE!  If you aggregated all the time spent by developers doing stupid hacks for IE... you could end world hunger.  It just sucks when you come across some really cool feature that is only supported by IE... I don't like giving that browser any credit.  It's like thanking the Nazis for all the technological advances made during their reign.

@philkeene - There seems to be some ActiveX plugin for firefox.  Based on the reviews, I wouldn't get your hopes up.



Onthrax, thanks for your solution, I believe that I am just going to have to be dictatorial on using IE.
Designbyonyx, it looks promising that someone has attempted that. Unfortunately it does look like although it may have worked right at the beginning, it is no longer working, but it does suggest that it may be possible to reimplement, or for someone else to do.
My solution... Specify IE 6, 7 and 8 as the only compatible browsers for the intranet, and use Onthrax's code to implement the mailer. If they require Firefox compatibility, I will do some further research into the add on solution, and if that is deemed infeasible I will have to revert to the server side mailing at least for firefox users.
Thank you both for all your help.

Glad I could help :). Don't forget to accept all answers that helped you..
I don't really feel like I contributed much.  Please award all points to Onthrax.


Thanks Designbyonyx, you've made my job easier, but if you do come up with any firefox solutions, then let me know and I'll open a new question for you to answer. Sorry about the delay on the points, I was diverted by something important for a mo.

Cheers :)

Sweet! Bookmarked :D


Wow that is excellent... stick the answer here...
... then I can give you some points for it. Felt bad about not being able to when you were so helpful, but this latest development is going to be a massive help.
I'll try and assign the points as quickly as possible for you, but I do have some personal stuff going on, so sorry if there is a delay at all.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.