DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

Excel and Email

This is a discussion on Excel and Email within the ASP Development forums, part of the Programming & Scripting category; Hello, I have professors you host extra traning classes and then students sign up for it. I am creating a ...

Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

  #1  
Old February 16th, 2009, 12:48 PM
Barn Newbie
 
Join Date: Feb 2009
Posts: 16
Rep Power: 2
Chrissy is an unknown quantity at this point
Default Excel and Email

Hello,

I have professors you host extra traning classes and then students sign up for it.


I am creating a web based section for the admin. So say for example a professor has a ASP.net class and he gets 4 students signed for it and the deadline for registration is over. The admin will log into his admin section see the professors name and click on the link which says Email.

When he does that a email should be sent to the Professor with the names of the student who signed for his class.

What I have done till now is get the data in excel(created a asp page and then open up excel in it). But I dont know how to save it at a specified location and then sent the email via Jmail.


Any thoughts on how to proceed with it.

Thanks

chrissy
Reply With Quote
  #2  
Old February 16th, 2009, 12:58 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

So you're trying to send an Excel document as an attachment in an email? Is the Excel file already located on the web server?

Here's a sample using JMail: 15 Seconds : Code Samples : Send Mail with Jmail
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
  #3  
Old February 16th, 2009, 01:01 PM
Barn Newbie
 
Join Date: Feb 2009
Posts: 16
Rep Power: 2
Chrissy is an unknown quantity at this point
Default

I have created a asp page where I have it where it opens in excel. I need to know how to save that excel that I created in ASP page on the server.
Reply With Quote
  #4  
Old February 16th, 2009, 03:00 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Quote:
Originally Posted by Chrissy View Post
I have created a asp page where I have it where it opens in excel. I need to know how to save that excel that I created in ASP page on the server.
If the file is generated by ASP code, then you can use the FileSystemObject to save it to the web server: ASP FileSystem Object
Reply With Quote
  #5  
Old February 16th, 2009, 03:49 PM
Barn Newbie
 
Join Date: Feb 2009
Posts: 16
Rep Power: 2
Chrissy is an unknown quantity at this point
Default

This is the code I have till now

Code:
<%
Response.ContentType = "application/vnd.ms-excel" 
 Response.AddHeader "Content-Disposition", "attachment;filename=members.xls"


idnumber=Trim(Request.querystring("id"))
Set rsproducts = Server.CreateObject("ADODB.Recordset")
strproducts="select * from Registration  where Id=" & idnumber & "'"
rsproducts.Open strproducts, Conn
%>
<head>
<title>Members</title>

</head>
<body style="margin: 0px 0px 0px 20px;">

<h2>Registered Users</h2>
<%
If rsproducts.eof then
	Response.write "No Members registered"


else

%>
<table width="650" title="Registered Members">
<thead>
<tr>

<th>Name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Phone</th>
<th>Country</th>
<th>Email</th>

</th>
</tr>
<tbody>
<%
Do while not rsproducts.eof
%>
<tr>
<td><%=rsproducts("First_Name")%>&nbsp;<%=rsproducts("Last_Name")%></td>
<td><%=rsproducts("Address")%></td>
<td><%=rsproducts("City")%></td>
<td><%=rsproducts("State")%></td>
<td><%=rsproducts("Zip")%></td>
<td><%=rsproducts("Phone")%></td>
<td><%=rsproducts("Country")%></td>
<td><%=rsproducts("Email")%></td>


<%

rsproducts.movenext
Loop

rsproducts.close
Set rsproducts=Nothing


%>



</thead>
</table>







<%
End if
%>
 </div>

</div>

</body>
</html>
Reply With Quote
  #6  
Old February 16th, 2009, 07:46 PM
Barn Newbie
 
Join Date: Feb 2009
Posts: 16
Rep Power: 2
Chrissy is an unknown quantity at this point
Default

So I need to know how to save the above excel file on the server and then take that path of the file and use it to sent the email.
Reply With Quote
  #7  
Old February 16th, 2009, 07:58 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

The code you posted will only generate an Excel document from the HTML on the page through the browser. It won't allow you to save it on the web server. You can look into using Office Web Components (OWC). See the following:

http://tutorial.jcwcn.com/Web-Design...6-30/1831.html
4GuysFromRolla.com - Creating Excel Spreadsheets with Office Web Components (OWC)
Reply With Quote
  #8  
Old February 16th, 2009, 08:42 PM
Barn Newbie
 
Join Date: Feb 2009
Posts: 16
Rep Power: 2
Chrissy is an unknown quantity at this point
Default

So I was looking at these lines of code
Code:
Class ExcelGen

  Private objSpreadsheet
  Private iColOffset
  Private iRowOffset

  Sub Class_Initialize()
    Set objSpreadsheet = Server.CreateObject("OWC.Spreadsheet")

    iRowOffset = 2
    iColOffset = 2
  End Sub

  Sub Class_Terminate()
    Set objSpreadsheet = Nothing   'Clean up
  End Sub

  ...
End Class
specially these 2 lines


iRowOffset = 2
iColOffset = 2

where it says how many cols and how many rows

the cols will be 12 but the rows I dont know as how many students sign will never be known

can u guide me on this one
Reply With Quote
  #9  
Old February 16th, 2009, 08:51 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

That's just to initialize everything. If you review the code further down, there are property Let constructs that allow you to change the offsets. Just be sure to actually read the content and not just the code so you understand what it's doing. Further towards the bottom is a sample on how to use the code in an ASP page.
Reply With Quote
  #10  
Old February 16th, 2009, 08:56 PM
Barn Newbie
 
Join Date: Feb 2009
Posts: 16
Rep Power: 2
Chrissy is an unknown quantity at this point
Default

Ok I get you now since I have read the whole article How can i fix the problem of saving as it will always save the file with same name.

Because currently I have 4 professors who have classes set up and If I sent the excel sheet to one person the same will be sent to other 3 also.

He doesnt tell me at the bottom of the page how he can fix the problem .

Can i create a file name by the recordset Id and date it was created in the SaveWorksheet function.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Email Tracking Code dr_rock ASP Code Samples 0 January 20th, 2009 10:54 PM
Sending Email with ASP and CDOSYS jmurrayhead ASP Code Samples 1 November 13th, 2008 09:26 AM
help with email validation Rebelle JavaScript Programming 13 August 21st, 2008 10:57 AM
[Email] Using dll to send email - Multithreading sync_or_swim ASP Development 1 August 4th, 2008 10:15 AM


All times are GMT -4. The time now is 06:57 AM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2