H
Henry Stock
I don't seem to understand how to use the value:
Request.ServerVariables("remote_addr")
I am trying to pass the ip address of a sending web client in the body of an
email message.
When I compile the following code I get the this error message:
Error 1 'System.Web.HttpRequest.ServerVariables' is a 'property' but is used
like a 'method' D:\Projects\sample\comments.aspx.cs 38 78
D:\Projects\sample\
For all I know, there may be more errors than just haven't shown their head
yet.
Can somebody tell me how to pass the value to my message?
//*****************************************************
protected void contactUS_Click(object sender, EventArgs e)
{
//Things to Do:
// Validate form fields:
// Name field should be letters and spaces only. Can't be blank or only
spaces.
// Phone field may have () - spaces and digits
// email address must be properly formatted.
// Eventually I would like to add a check for domain validity
// After edits I need to create the message
MailMessage msg = new MailMessage();
MailAddress _from = new MailAddress(FindControl("email").ToString());
MailAddress _sender = new MailAddress("(e-mail address removed)");
msg.From = _from;
msg.Sender = _sender;
msg.Subject = "Feedback from Comments Form";
StringBuilder sbuilder = new StringBuilder();
//Build string for message body
sbuilder.AppendLine("Sender's IP Address: " +
Response.Write(Request.ServerVariables("remote_addr")));
sbuilder.AppendLine("Name: " + FindControl("name").ToString());
sbuilder.AppendLine("Phone: " + FindControl("phone").ToString());
sbuilder.AppendLine("Email: " + FindControl("email").ToString());
sbuilder.AppendLine("Message: " + FindControl("message").ToString());
//assign string value to message body
msg.Body = sbuilder.ToString();
//create the smtp client
SmtpClient _smtp = new SmtpClient();
_smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
_smtp.Host = "mrelay.perfora.net";
_smtp.Port = 25;
_smtp.Send(msg);
}
//**************************************************
Request.ServerVariables("remote_addr")
I am trying to pass the ip address of a sending web client in the body of an
email message.
When I compile the following code I get the this error message:
Error 1 'System.Web.HttpRequest.ServerVariables' is a 'property' but is used
like a 'method' D:\Projects\sample\comments.aspx.cs 38 78
D:\Projects\sample\
For all I know, there may be more errors than just haven't shown their head
yet.
Can somebody tell me how to pass the value to my message?
//*****************************************************
protected void contactUS_Click(object sender, EventArgs e)
{
//Things to Do:
// Validate form fields:
// Name field should be letters and spaces only. Can't be blank or only
spaces.
// Phone field may have () - spaces and digits
// email address must be properly formatted.
// Eventually I would like to add a check for domain validity
// After edits I need to create the message
MailMessage msg = new MailMessage();
MailAddress _from = new MailAddress(FindControl("email").ToString());
MailAddress _sender = new MailAddress("(e-mail address removed)");
msg.From = _from;
msg.Sender = _sender;
msg.Subject = "Feedback from Comments Form";
StringBuilder sbuilder = new StringBuilder();
//Build string for message body
sbuilder.AppendLine("Sender's IP Address: " +
Response.Write(Request.ServerVariables("remote_addr")));
sbuilder.AppendLine("Name: " + FindControl("name").ToString());
sbuilder.AppendLine("Phone: " + FindControl("phone").ToString());
sbuilder.AppendLine("Email: " + FindControl("email").ToString());
sbuilder.AppendLine("Message: " + FindControl("message").ToString());
//assign string value to message body
msg.Body = sbuilder.ToString();
//create the smtp client
SmtpClient _smtp = new SmtpClient();
_smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
_smtp.Host = "mrelay.perfora.net";
_smtp.Port = 25;
_smtp.Send(msg);
}
//**************************************************