Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automatically log into a website and send a message

Status
Not open for further replies.

legos

Programmer
Jul 2, 2003
151
US
I have a website and I am trying to implement a mass messaging script.
These are the steps that I need to take
1. go to page "2. automatically Submit Username and Password values
3. Go to page "4. automatically Submit message values

Here is what I have come up with so far:
Opening this page will log me into my website automatically
login.html
Code:
<form METHOD="POST" name="FrontPage_Form1" ACTION="[URL unfurl="true"]http://www.mywebsite.com/login.asp">[/URL]

<input type="hidden" name="Username" value="">
<input type="hidden" name=Password value="">         
            
</form>
<script type="text/javascript" language="JavaScript"><!--
document.FrontPage_Form1.Username.value = "Username";
document.FrontPage_Form1.Password.value ="Password";
document.FrontPage_Form1.submit(); 
//--></script>
When manually logging into my website I can click open this page and it will perform the send function that I want it to.
message.html
Code:
<form METHOD="POST" name="FrontPage_Form1" ACTION="[URL unfurl="true"]http://www.mywebsite.com/compose.asp?">[/URL]

<input type="hidden" name="messaging_toid" value="">
<input type="hidden" name=messaging_subject value="">
<input type="hidden" name="from" value="">
<input type="hidden" name=messaging_message value="">
<input type="hidden" name="MM_insert" value="">           
            
</form>
<script type="text/javascript" language="JavaScript"><!--
document.FrontPage_Form1.messaging_toid.value = "SendTo";
document.FrontPage_Form1.messaging_subject.value ="Message Subject";
document.FrontPage_Form1.from.value  = "UserNamel";
document.FrontPage_Form1.messaging_message.value = "Message Text";
document.FrontPage_Form1.MM_insert.value = "form1";
document.FrontPage_Form1.submit(); 
//--></script>

What I need to do now is combine these two HTML files into a program that will log into my site and send out the message. I have also written a program that takes all of the html for any webpage and writes it to a string. I also need to use this file so that I can make a database of users to send the message to.

Code:
static void Main(string[] args)
        {
            // used to build entire input
            StringBuilder sb = new StringBuilder();

            // used on each read operation
            byte[] buf = new byte[8192];

            // prepare the web page we will be asking for
            string URL;
            for (int i = 0; i < 1; i++)
            {
                URL = String.Concat("[URL unfurl="true"]http://www.mywebsite.com/display.asp?ID=",[/URL] Convert.ToString(i));
                HttpWebRequest request = (HttpWebRequest)
                    WebRequest.Create(URL);

                // execute the request
                HttpWebResponse response = (HttpWebResponse)
                    request.GetResponse();

                // we will read data via the response stream
                Stream resStream = response.GetResponseStream();

                string tempString = null;
                int count = 0;

                do
                {
                    // fill the buffer with data
                    count = resStream.Read(buf, 0, buf.Length);

                    // make sure we read some data
                    if (count != 0)
                    {
                        // translate from bytes to ASCII text
                        tempString = Encoding.ASCII.GetString(buf, 0, count);

                        // continue building the string
                        sb.Append(tempString);
                    }
                }
                while (count > 0); // any more data to read?

                // print out page source
                String Teststring = sb.ToString();
                Console.WriteLine(Teststring);
            }
        }

Durible Outer Casing to Prevent Fall-Apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top