Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Client side mailing with attachments

Posted on 2010-09-15
19
636 Views
Last Modified: 2012-06-27
Hi,

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.

Thanks,

Phil
0
Comment
Question by:philkeene
  • 7
  • 6
  • 6
19 Comments
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 33686636
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.
0
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 33686757
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.
0
 
LVL 13

Accepted Solution

by:
Onthrax earned 500 total points
ID: 33686763
You would need to use ActiveX for this to work. However this is only supported in IE (so the two firefox users would have to switch).

for example:

var outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.add('IPM.Note.FormA');
mailItem.Subject="CUSTOMER SERVICE";
mailItem.To = document.frmM.txtEmail.value;
mailItem.HTMLBody = "SOME HTML CODE";
mailitem.Attachements.Add ("C:\\temp\\xxx.txt");
mailItem.display (0);

0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 13

Expert Comment

by:Onthrax
ID: 33686778
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 ;)
0
 
LVL 4

Author Comment

by:philkeene
ID: 33686846
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.
0
 
LVL 13

Expert Comment

by:Onthrax
ID: 33686887
It's just javascript. Simply put it inside a function within <script></script> tags and it'll work just fine :)
0
 
LVL 4

Author Comment

by:philkeene
ID: 33686899
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.
0
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 33686928
@Onthrax - leave it to IE to do all sorts of cool stuff, EXCEPT for rendering html ;)

Amidst my curiosity, I found this:

http://stackoverflow.com/questions/1195111/c-mailto-with-attachment#answer-1352273

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.
0
 
LVL 4

Author Comment

by:philkeene
ID: 33687192
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.

<script>
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);
</script>
E-mail opened!

Open in new window

0
 
LVL 13

Expert Comment

by:Onthrax
ID: 33689448
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.
0
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 33692499
@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.

https://addons.mozilla.org/en-US/firefox/addon/8265/
0
 
LVL 4

Author Comment

by:philkeene
ID: 33695239
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.
0
 
LVL 13

Expert Comment

by:Onthrax
ID: 33695917
Glad I could help :). Don't forget to accept all answers that helped you..
0
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 33696001
I don't really feel like I contributed much.  Please award all points to Onthrax.
0
 
LVL 4

Author Comment

by:philkeene
ID: 33696973
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.
0
 
LVL 13

Expert Comment

by:Onthrax
ID: 33697003
Cheers :)
0
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 33697140
0
 
LVL 13

Expert Comment

by:Onthrax
ID: 33699204
Sweet! Bookmarked :D
0
 
LVL 4

Author Comment

by:philkeene
ID: 33732440
Wow that is excellent... stick the answer here...
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/HTML/Q_26490765.html
... 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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question