Create Excel Documents and E-mail them

oafc0000

Member
Joined
Jan 28, 2003
Messages
18
Hi All

I am developing a application that needs to create a excel document and e-mails it to the recpeitent all server side.

The user will fill in a html form and then submit it, then data is then place in excel and then mailed out.

Anybody know any way of doing this on the server so the user is still only sending and receving html to the sever and not using excel on there PC??

Thanks
 
So you want to generate the XLS file, but not really launch Excel (at least visibly to the user), then email the XLS file you generated to somewhere? All this being done on the server, I have that much right?

Im not sure about your first problem (Ive only exported a datagrid to Excel, but its shown to the user on purpose in those cases).

For the second part of your question heres a way in VB.net/ASP.Net:

Imports System.Web.Mail

Protected Sub CreateAndSendEmail(ByVal fromID As String, ByVal fromName As String, ByVal To_Email As String, ByVal CC_Email As String)
Dim strSubject As String
Dim msgMail As New MailMessage()
Dim stbMessageBody As New System.Text.StringBuilder()

Try
CREATE MESSAGE BODY
stbMessageBody.Append("Hey - you have mail.")

CREATE MESSAGE HEADER
strSubject = "A new QA Feedback Survey is available."

msgMail.From = fromID
msgMail.To = To_Email
msgMail.Cc = CC_Email
msgMail.Body = stbMessageBody.ToString
msgMail.Subject = strSubject
SmtpMail.SmtpServer = "mail.yourdomain.com"
SmtpMail.Send(msgMail)
Catch ex As Exception
Throw ex
End Try
msgMail = Nothing

End Sub
 
The first part is pretty straight forward too.

If your data is going straight into a simple spreadsheet with no formatting, you can simply output it is a tab separated text file with an xls extension. Cheating slightly, but its smple and works
 
OK

Ive tried to attach the excel object
Problem: I get an error message when I try and add a COM
reference to Microsoft Excel Object Library

Is there any way I can do this as I dont have a lot of time to play with

cheers again
ZuBiE
 
Back
Top