Error sending ASPX pages in HTML mail 
Author Message
 Error sending ASPX pages in HTML mail

Hi guys,

I use the code below to send HTML emails to my customers, but when I try to
send an ASPX page, I get the following error message:
"Exception Details: System.Net.WebException: The remote server returned an
error: (500) Internal Server Error."

Here's the code:

        Dim client As WebClient = New WebClient()
        Dim buffer() As Byte = client.DownloadData(" http://www.*-*-*.com/ ")
        Dim str As String = Encoding.ASCII.GetString(buffer)

        Dim mail As MailMessage = New MailMessage()

        mail.UrlContentBase = "http://xxxx"


        mail.Subject = "test"
        mail.Body = str
        mail.Priority = MailPriority.Normal
        mail.BodyFormat = MailFormat.Html

        SmtpMail.SmtpServer = "mailrelay.bostream.com"

        SmtpMail.Send(mail)

The page works just fine when accessing it in a web browser. What could be
wrong?

Regards,
Jonah Olsson



Fri, 14 Oct 2005 22:17:35 GMT  
 Error sending ASPX pages in HTML mail
Examine the log file and see what was asked to be served up. You may find an
error here.

Another thing to remember. HTML mail is designed to send HTML to a user in
place of text, not necessarily to serve up pages and then send them to
someone. The norm is to make an HTML template with a section that can be
replaced with each email. You then stick a piece of HTML in the middle. Your
method, while not necessarily "wrong," is certainly unorthodox.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think Outside the Box!
****************************************************************************
****

Quote:
> Hi guys,

> I use the code below to send HTML emails to my customers, but when I try
to
> send an ASPX page, I get the following error message:
> "Exception Details: System.Net.WebException: The remote server returned an
> error: (500) Internal Server Error."

> Here's the code:

>         Dim client As WebClient = New WebClient()
>         Dim buffer() As Byte = client.DownloadData("http://xxxx.aspx")
>         Dim str As String = Encoding.ASCII.GetString(buffer)

>         Dim mail As MailMessage = New MailMessage()

>         mail.UrlContentBase = "http://xxxx"


>         mail.Subject = "test"
>         mail.Body = str
>         mail.Priority = MailPriority.Normal
>         mail.BodyFormat = MailFormat.Html

>         SmtpMail.SmtpServer = "mailrelay.bostream.com"

>         SmtpMail.Send(mail)

> The page works just fine when accessing it in a web browser. What could be
> wrong?

> Regards,
> Jonah Olsson



Fri, 14 Oct 2005 22:25:15 GMT  
 Error sending ASPX pages in HTML mail
Gregory,

Thanks for your quick reply.
I tried to run the code on my test machine, locally, and got a different
error message:
"Exception Details: System.Net.WebException: The remote server returned an
error: (401) Unauthorized."

The reason I use this method is that the web site should look exactly like
the mail.
Why do you think this is an unorthodox method? I can't really see the
difference between an ordinary HTML mail, where the content is an external
HTML file inserted into the mail, and this method. I see more power with
this method since it's dynamic.

Btw, the code works perfectly with non aspx pages. But do you think I will
encounter other problems with this method?

Thanks.
/Jonah



Quote:
> Examine the log file and see what was asked to be served up. You may find
an
> error here.

> Another thing to remember. HTML mail is designed to send HTML to a user in
> place of text, not necessarily to serve up pages and then send them to
> someone. The norm is to make an HTML template with a section that can be
> replaced with each email. You then stick a piece of HTML in the middle.
Your
> method, while not necessarily "wrong," is certainly unorthodox.



Fri, 14 Oct 2005 22:51:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. sending html mail from asp page using mailmessage

2. Sending current HTML/ASP page as mail

3. Sending current HTML/ASP page as mail

4. Merge Pdf and aspx(html) pages

5. Help sending HTML mail in mail merge

6. sending HTML-Mail with images and not using ActiveDocument.send

7. strange error trying to delete file with .aspx page (security policy, trust level BS)

8. strange error trying to delete file with .aspx page (security policy, trust level BS)

9. Send Mail Without Leaving Message in Sent Mail

10. send html mail

11. Sending Mail with Html Body

12. Sending Out Multiple HTML Mails By VBA in Outlook XP

 

 
Powered by phpBB® Forum Software