Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-29-2012, 04:15 PM   PM User | #1
jpcsolutions
New to the CF scene

 
Join Date: Nov 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
jpcsolutions is an unknown quantity at this point
Checkbox to Email Creation with Attachment

Hi everybody…

As you can see by the markup below, there is an image, which has a checkbox next to it. There are about 15 different documents laid out on this particular page. All these documents would be pre-loaded onto the server. My goal here is to have the end user check off all the appropriate documents and then click a button that says, ‘Generate Email’ (or something along those lines). This is part of an internal application. Everybody’s native email client is MS Outlook. When the ‘Generate Email’ button is clicked, an email will open up and have those checked off documents attached to the email. The user enters an email address, and hits send.

I am sure this is possible, but is it something that JS can do?

I'm fairly new to JS, but I'm willing to learn what I need to. I just need to be pushed in the right direction.

Code:
<div class="col one_fourth gallery_box"> <a href="images/docs/POP_Form.jpg" 
rel="lightbox[docs]"><img src="images/docs/POP_Form.jpg" 
alt="" width="74" height="95" class="image_frame"/></a>
 <h5>Student Payment Option </h5>
 <h5>Policy Agreement (POP Form) </h5>
 <h5><font color="#990000"><a href="docs/POP Form.pdf" target="_blank">
<strong>Click here for the PDF</strong></a></font></h5>
 <h5> <span id="sprycheckbox3">
  <input type="checkbox" name="pop_form" id="pop_form" tabindex="40" />
    <label for="pop_form">Send this form in an email</label>
    <span class="checkboxRequiredMsg">Please make a selection.</span></span></h5>
</div>

I know that a mail scripts usually send a file uploaded by a user, but in this case, I need to change the script to allow the user to select files which already reside on the server.

Thanks in advance!

-JPC Solutions
jpcsolutions is offline   Reply With Quote
Old 12-29-2012, 06:09 PM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
this is untested, but as far as I am aware, if everybody is using IE it can be done. In the below, you need to give each checkbox which refers to a file a class of "doc" and a value which corresponds to the full path to the filename. I don't know if filenames with spaces will work - you may have to escape the whole string. I don't have outlook so can't test it, but it seems like it would be something like this:

Code:
<body>
<div class="col one_fourth gallery_box"> 
<a href="images/docs/POP_Form.jpg" 
rel="lightbox[docs]"><img src="images/docs/POP_Form.jpg" 
alt="" width="74" height="95" class="image_frame"/></a>
 <h5>Student Payment Option </h5>
 <h5>Policy Agreement (POP Form) </h5>
 <h5><font color="#990000"><a href="docs/POP Form.pdf" target="_blank">
<strong>Click here for the PDF</strong></a></font></h5>
 <h5> <span id="sprycheckbox3">
  <input type="checkbox" name="pop_form" id="pop_form" class="doc" value="http://192.168.0.461:87/docs/POP Form.pdf" tabindex="40" />
    <label for="pop_form">Send this form in an email</label>
    <span class="checkboxRequiredMsg">Please make a selection.</span></span></h5>
</div>
<input type="button" value="send email" onclick="sendMail()"/>
<script type='text/javascript'>
function sendMail(){
  objOutlookExpress = new ActiveXObject("Outlook.Application");
  objOutlookMsg = objOutlookExpress.CreateItem(0)
  objOutlookMsg.To = "";//add email address here
  objOutlookMsg.Subject = "your documents";
  objOutlookMsg.HTMLBody = "Here are the documents you requested";
  var inps=document.getElementsByTagName("input");
    for (var i = 0; i < inps.length; i++) {
  if(inps[i].className="doc"&&inps[i].checked){
  objOutlookMsg.Attachments.Add(inps[i].value);
			}
	}
}
</script>
</body>

Last edited by xelawho; 12-29-2012 at 06:16 PM..
xelawho is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:16 PM.


Advertisement
Log in to turn off these ads.