Solved

Client side mailing with attachments

Posted on 2010-09-15
19
630 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now