S
shil
Hi,
I'm using FW 2.0 to send an email with an attachment using
System.Net.Mail class. If I try to attach a file from my file system,
I could successfully send the eamil. But I need to generate a report
on the fly and send an email with that report as an attachment. Here
is the code I have.
-----------------------------------------------------------
Dim Server as string, File as string
Dim mailClient As SmtpClient = New SmtpClient()
Dim msgFrom As String, msgTo As String, msgBody As String, msgSubject
As String
msgFrom = "(e-mail address removed)"
msgTo = "(e-mail address removed)"
msgSubject = "Your Report"
msgBody = "Attached is your report:"
Dim msg As New Net.Mail.MailMessage(msgFrom, msgTo, msgSubject,
msgBody)
mailClient.UseDefaultCredentials = True
mailClient.Host = "SMTPServer"
mailClient.Port = "25"
Server = "http://MyServer/Root/"
File = Server & "GenerateReport.aspx?ReportID=1"
msg.Attachments.Add(New Attachment(File, "text/plain"))
mailClient.Send(msg)
--------------------------------------------------------
When I execute the above code, I get an error "URI formats are not
supported."
But if I attach a file from my file system, it works fine.
Can any one direct me in a right direction?
Thanks.
I'm using FW 2.0 to send an email with an attachment using
System.Net.Mail class. If I try to attach a file from my file system,
I could successfully send the eamil. But I need to generate a report
on the fly and send an email with that report as an attachment. Here
is the code I have.
-----------------------------------------------------------
Dim Server as string, File as string
Dim mailClient As SmtpClient = New SmtpClient()
Dim msgFrom As String, msgTo As String, msgBody As String, msgSubject
As String
msgFrom = "(e-mail address removed)"
msgTo = "(e-mail address removed)"
msgSubject = "Your Report"
msgBody = "Attached is your report:"
Dim msg As New Net.Mail.MailMessage(msgFrom, msgTo, msgSubject,
msgBody)
mailClient.UseDefaultCredentials = True
mailClient.Host = "SMTPServer"
mailClient.Port = "25"
Server = "http://MyServer/Root/"
File = Server & "GenerateReport.aspx?ReportID=1"
msg.Attachments.Add(New Attachment(File, "text/plain"))
mailClient.Send(msg)
--------------------------------------------------------
When I execute the above code, I get an error "URI formats are not
supported."
But if I attach a file from my file system, it works fine.
Can any one direct me in a right direction?
Thanks.