[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 645
  • Last Modified:

Client side mailing with attachments

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
philkeene
Asked:
philkeene
  • 7
  • 6
  • 6
1 Solution
 
DesignbyonyxCommented:
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
 
DesignbyonyxCommented:
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
 
OnthraxCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
OnthraxCommented:
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
 
philkeeneAuthor Commented:
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
 
OnthraxCommented:
It's just javascript. Simply put it inside a function within <script></script> tags and it'll work just fine :)
0
 
philkeeneAuthor Commented:
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
 
DesignbyonyxCommented:
@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
 
philkeeneAuthor Commented:
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
 
OnthraxCommented:
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
 
DesignbyonyxCommented:
@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
 
philkeeneAuthor Commented:
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
 
OnthraxCommented:
Glad I could help :). Don't forget to accept all answers that helped you..
0
 
DesignbyonyxCommented:
I don't really feel like I contributed much.  Please award all points to Onthrax.
0
 
philkeeneAuthor Commented:
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
 
OnthraxCommented:
Cheers :)
0
 
DesignbyonyxCommented:
0
 
OnthraxCommented:
Sweet! Bookmarked :D
0
 
philkeeneAuthor Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now