Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- .NET Development
- :
- How to post data to salesforce
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to post data to salesforce
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-22-2012 04:11 AM
Hi, Can anyone pls help me how to pass the data from webtolead to salesforce in c#.
This is my code.
protected void btnSubmit_Click(object sender, EventArgs e)
{
Page.Validate();
if (Page.IsValid)
{
StringBuilder data = new StringBuilder();
data.Append("oid=" + oid.Value);
//data.Append("&retURL=" + Server.UrlEncode("http://www.myweb.co/contact/messagesent.aspx"));
data.Append("&retURL=" + retURL.Value);
data.Append("&first_name=" + Server.UrlEncode(first_name.Value));
data.Append("&last_name=" + Server.UrlEncode(last_name.Value));
data.Append("&email=" + Server.UrlEncode(email.Value));
//Post the data
byte[] buffer = System.Text.Encoding.GetEncoding("UTF-8").GetBytes
string url = "https://www.salesforce.com/servlet/servlet.WebToLe
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
buffer = Encoding.UTF8.GetBytes(data.ToString());
req.ContentLength = buffer.Length;
using (Stream reqst = req.GetRequestStream())
{
reqst.Write(buffer, 0, buffer.Length);
}
}
}

