Sponsored by
www.aspnetemail.com
|
 |
Discuss This FAQ Item
Got a question? Another Suggestion? Want to post your solution? Discuss it below.
-
url as meessage content
[ Reply ]
Hi when i run the code below, everything freeze on this line: StreamReader sr = new StreamReader( objRequest.GetResponse().GetResponseStream() ); and i see frozen console on monitor and afer that and exception message. do you know why?
Parastoo Tahmasebi [ ptahmasebi ( at ) garrisons dot com dot au ],
2004-02-02 19:20:21
#
-
RE: url as meessage content
[ Reply ]
Hi, Thats probably coz of teh delay that takes place in attempting to read the source HTML. What is the error you get at the end of it all? Server Not Available?
Vikas [ vikask ( at ) iniquus dot com ],
2004-03-02 00:06:31
#
-
RE: url as meessage content
[ Reply ]
I'm looking to gather the results from a form submission and email it off. The forms are completely dynamic, so I do not know anything about them. I was hoping to capture the innerhtml property of the body or a div after postback and write that to the email body. But I can not get that to work. Any Ideas!
I don't think I can use the technique discribed here since the URL is specific to the post back.
Jonathan [ Jonathan dot Porter ( at ) ppww dot org ],
2004-04-09 09:20:41
#
-
Code above issues with some sites.
[ Reply ]
I used this code above and it works as advertised for some sites (aka microsoft.com) but a site like http://www.slickdeals.net (and others) is there a reason this will work for one site and not another?
marc
marc gold [ marc ( at ) lrau dot com ],
2004-05-10 18:27:45
#
-
Code above issues with some sites.
[ Reply ]
I used this code above and it works as advertised for some sites (aka microsoft.com) but a site like http://www.slickdeals.net (and others) is there a reason this will work for one site and not another?
marc
marc gold [ marc ( at ) lrau dot com ],
2004-05-11 18:21:09
#
-
How to send the url as a link!
[ Reply ]
I will like to know how to send the url as a link! I try this code: http://primo.europe.webmatrixhosting.net/Codenavigateurl.htm This is the app http://primo.europe.webmatrixhosting.net/Vision But I get the url in diferent format! and you can't clicked THX Primo :) Regards
Gerardo [ primillo77 ( at ) hotmail dot com ],
2004-07-05 16:11:17
#
-
Sending a page containing sessions variables
[ Reply ]
Hi, I'm trying to use this code to send a page containing a table filled in with session variables. The email received contains the table but the field supposed to contain the session variables are blank. Does anyone know if it is actually possible to do that or not with the scraping function above?
Tom [ atom267 ( at ) hotmail dot com ],
2004-11-17 04:51:29
#
-
RE: Sending a page containing sessions variables
[ Reply ]
that's probably because it is using a different session than you are seeing.
cheers! Dave
dave wanta [ dave ( at ) 123aspx dot com ],
2004-11-17 05:09:38
#
-
RE RE: Sending a page containing sessions variables
[ Reply ]
Actually when I open the page I am sending by email ( that is I type its url in my browser and load it), all the fields are correctly displayed. It is only the content of the mail that is not correct, it looks like the function above does not allow to pick up session values in my example. Basically, when a form is sent, DB is updated, session variables are created, then I send the content of emailsent.aspx by email with the function above. If i open emailsent.aspx, it will display my table properly, but the email only contains blank fields instead of the value i am expecting. Do you know what I mean? I think the values are lost with the scraping function. Any ideas? Thanks a lot, Thomas
Tom [ atom267 ( at ) hotmail dot com ],
2004-11-18 04:22:41
#
-
RE: RE RE: Sending a page containing sessions variables
[ Reply ]
and does the code doing the sending have access to the same session store your browser does?!? Are they trading cookies?!? Did you create a cookie container aond populate it?
I don't think you quite understand how the web works and it's stateless nature.
dave wanta [ dave ( at ) 123aspx dot com ],
2004-11-18 04:38:43
#
-
RE RE: RE RE: Sending a page containing sessions variables
[ Reply ]
No reason to be aggressive. I have found a way to do what i want but I have to recreate the page and send it as a html string in the body of the email. I just wanted to avoid that burden. Cheers, Thomas
Tom [ atom267 ( at ) hotmail dot com ],
2004-11-18 04:47:35
#
-
RE RE: RE RE: Sending a page containing sessions variables
[ Reply ]
No reason to be aggressive. I have found a way to do what i want but I have to recreate the page and send it as a html string in the body of the email. I just wanted to avoid that burden. Cheers, Thomas
Tom [ atom267 ( at ) hotmail dot com ],
2004-11-18 06:03:05
#
-
RE RE: RE RE: Sending a page containing sessions variables
[ Reply ]
No reason to be aggressive. I have found a way to do what i want but I have to recreate the page and send it as a html string in the body of the email. I just wanted to avoid that burden. Cheers, Thomas
Tom [ atom267 ( at ) hotmail dot com ],
2004-11-18 06:05:08
#
-
RE RE: RE RE: Sending a page containing sessions variables
[ Reply ]
No reason to be aggressive. I have found a way to do what i want but I have to recreate the page and send it as a html string in the body of the email. I just wanted to avoid that burden. Cheers, Thomas
Tom [ atom267 ( at ) hotmail dot com ],
2004-11-18 06:07:10
#
-
Pictures are not Available in Mail
[ Reply ]
Hello everybody,
I tried the following code and found some problem. When you send the mail following code it capture the html and send it by the email. But when you view that email you can see only text but not graphcs because graphics were embeded locally not globlally using url system. Anybody have an idea how to solve this problem.
Arvind Sedha [ arvindsedha ( at ) hotmail dot com ],
2005-06-12 09:46:06
#
-
RE: Pictures are not Available in Mail
[ Reply ]
This will be down to the page which you're reading via the webrequest.
Ensure that the page is providing the full URL for each of the images, not simply a relative path name and this should be fine.
If you don't have control over the page in question, then you may find that with simple img tags you could parse the string (result) and find any img tags, check the src property and if it wasn't a fully qualified url you could rebuild and replace the src with a new one using the url passed in as a parameter as the source.
May be more hassle than it's worth, but anythings doable.
Tony [ no ( at ) spam dot com ],
2006-05-18 04:28:15
#
-
bad url and exception
[ Reply ]
If url is a bad url occurs an exception with pending IO streaming connection. This may be a
problem. I prefer generate an exception using:
System.Net.WebClient myWebClient = new System.Net.WebClient(); byte[] bResult = myWebClient.DownloadData(url);
Do you have any suggestion about it?
Hi Diego.
niyonanomhmatahmomandyin [ gdmail ( at ) libero dot it ],
2005-07-12 07:13:22
#
-
RE: bad url and exception
[ Reply ]
For close any pending IO streaming connection:
public static string HttpContent(string url) { string result; System.Net.WebRequest objRequest= System.Net.HttpWebRequest.Create(url); System.IO.StreamReader sr = null; try { sr = new System.IO.StreamReader(objRequest.GetResponse().GetResponseStream()); result = sr.ReadToEnd(); } catch { result = string.Empty; } finally { sr.Close(); } return result; }
niyonanomhmatahmomandyin [ gdmail ( at ) libero dot it ],
2005-07-27 00:53:02
#
-
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
[ Reply ]
I am gettig the error:
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Whena I am using VB.Net code to send an email with the web page Here is the cod ei am using
Dim mail As New MailMessage mail.To = "mytestemail@mysite.com" mail.From = "mytestemail1@mysite.com" mail.Subject = "this is a test email." Dim url As String = "http://localhost" & Request.ServerVariables("URL") mail.Body = HttpContent(url) mail.BodyFormat = MailFormat.Html mail.UrlContentBase = url SmtpMail.SmtpServer = "servername" SmtpMail.Send(mail)
Private Function HttpContent(ByVal url As String) As String Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(url) Dim sr As New StreamReader(objRequest.GetResponse().GetResponseStream()) Dim result As String = sr.ReadToEnd() sr.Close() Return result End Function
jsquare [ jsquareshah ( at ) gmail dot com ],
2005-12-30 08:53:47
#
-
RE: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
[ Reply ]
Hi,
I actually got the same error message, when I was trying to access the localhost.
The web application is in C#, and I used the C# version code. The web application is trying to send the current web page to somebody through email, and I got the current URL using "Request.Url.AbsoluteUri", but when I access it, I got the error message:
The remote server returned an error: (401) Unauthorized. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Source Error:
Line 90: { Line 91: WebRequest objRequest= System.Net.HttpWebRequest.Create(url); Line 92: StreamReader sr = new StreamReader( objRequest.GetResponse().GetResponseStream() ); Line 93: string result = sr.ReadToEnd(); Line 94: sr.Close();
Source File: c:\work\aes2\code\interviewsummaryreport.aspx.cs Line: 92
Stack Trace:
[WebException: The remote server returned an error: (401) Unauthorized.] System.Net.HttpWebRequest.CheckFinalStatus() System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) System.Net.HttpWebRequest.GetResponse() AESWeb.InterviewSummaryReport.HttpContent(String url) in c:\work\aes2\code\interviewsummaryreport.aspx.cs:92 AESWeb.InterviewSummaryReport.SendEmail() in c:\work\aes2\code\interviewsummaryreport.aspx.cs:82 AESWeb.InterviewSummaryReport.btnEmail_Click(Object sender, EventArgs e) in c:\work\aes2\code\interviewsummaryreport.aspx.cs:227 System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()
Can somebody please help me out?
Thanks in advance,
Karen.
karen [ kyang94 ( at ) gmail dot com ],
2006-10-30 15:30:13
#
-
RE RE: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
[ Reply ]
I'm having the same issue, the same url that i'm trying to access works fine when I use internet explorer. Is there a limit on how long the url path can be? The Authentication is being passed in correctly however I still get the following error: The remote server returned an error: (401) Unauthorized. at aspNetEmail.EmailMessage.?(String , Exception ) at aspNetEmail.EmailMessage.AppendBodyFromUrl(String url, Boolean followRedirects, Boolean setUrlContentBase, Boolean setHtmlBaseTag, MailEncoding contentTransferEncoding, Boolean autoEmbedImages, EmbedImageOption embedImageOption) at aspNetEmail.EmailMessage.AppendBodyFromUrl(String url, Boolean followRedirects, Boolean autoEmbedImages
Z [ zman11 dot geo ( at ) yahoo dot com ],
2006-11-06 12:42:15
#
-
Error in mailing a webpage
[ Reply ]
Hi Whenenevr I try to mail my webpage on the click of a button I get the following error:
The remote server returned an error: (401) Unauthorized.
Here's the code m using
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mymail As New MailMessage() Dim mailcontenturl As String = "http://localhost:9000/mailchk.WebForm1.aspx" mymail.From = "ashima@yahoo.com" mymail.To = "ashima@gmail.com" mymail.Subject = "Test Mail Delivery" mymail.BodyFormat = MailFormat.Html mymail.Body = getHTML(mailcontenturl) mymail.Priority = MailPriority.High mymail.UrlContentBase = mailcontenturl SmtpMail.Send(mymail) Response.Write("mail sent")
End Sub
Private Function getHTML(ByVal url As String) As String
Dim wreq As WebRequest wreq = System.Net.HttpWebRequest.Create(url) Dim sr As New StreamReader(wreq.GetResponse().GetResponseStream()) Dim result As String = sr.ReadToEnd() sr.Close() wreq.Timeout = 10000 Return result
End Function
How can I fix this?
Regards, Ashima
Ashima [ ashima515 ( at ) yahoo dot com ],
2006-11-22 01:45:02
#
-
send page
[ Reply ]
how do i use this code in the html page? Private Sub Page_Load(sender As Object, e As System.EventArgs) Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." Dim url As String = "http://www.microsoft.com" mail.Body = HttpContent(url) mail.BodyFormat = MailFormat.Html mail.UrlContentBase = url SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail) End Sub 'Page_Load
'screen scrape a page here Private Function HttpContent(url As String) As String Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(url) Dim sr As New StreamReader(objRequest.GetResponse().GetResponseStream()) Dim result As String = sr.ReadToEnd() sr.Close() Return result End Function
maryam [ mary64 ( at ) gmail dot com ],
2007-01-06 02:31:49
#
-
send web page
[ Reply ]
how do use this code ? i dont work vb.net for web . do write this code to notepad. thanks you.
maryam [ mary64 ( at ) gmail dot com ],
2007-01-14 20:34:31
#
-
RE: send web page
[ Reply ]
.net give an eror about (WebRequest) like this BC30002: Type 'WebRequest' is not defined
Line 20: 'screen scrape a page here Line 21: Private Function HttpContent(url As String) As String Line 22: Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(url) Line 23: Dim sr As New StreamReader(objRequest.GetResponse().GetResponseStream()) Line 24: Dim result As String = sr.ReadToEnd()
pedram [ pedram_sat2010 ( at ) yahoo dot com ],
2007-03-01 14:11:46
#
|