using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Configuration;
public partial class player_roger_send_form : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string sOrgID, sPostData, sPostToURL, fname, lname, strTitle, strRole, strCompany, strCompanySize, strCountry, strEmail, strPhone, strPhoneExt, campaign, campaignid;
sOrgID = "xxxx";
campaign = "xxxxx";
campaignid = "xxxxxx";
sPostToURL = "https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8";
// Fill variables with form data
fname = Request.Form["First Name"];
lname = Request.Form["Last Name"];
strTitle = Request.Form["Title"];
strRole = Request.Form["Role"];
strCompany = Request.Form["Company"];
strCompanySize = Request.Form["Company Size"];
strCountry = Request.Form["COuntry"];
strEmail = Request.Form["Email"];
strPhone = Request.Form["Phone"];
strPhoneExt = Request.Form["Phone Ext"];
if (fname != null)
{
// Create string to send to SFDC
sPostData = "&lead_source=Web" +
"&00N30000001FBQO=inquiry" +
"&00N30000001GFL5=" + campaign +
"&Campaign_ID=" + campaignid +
"&external=1" +
"&oid=" + sOrgID +
"&first_name=" + fname +
"&last_name=" + lname +
"&company=" + strCompany +
"&00N30000001FCNQ=" + strCompanySize +
"&00N30000001Gqqe=" + strRole +
"&title=" + strTitle +
"&00N30000001FpGY=" + strCountry +
"&email=" + strEmail +
"&00N60000001g2Z6= Filled out form after watching videos by xxxxx" +
"&phone=" + strPhone + "Ext:" + strPhoneExt +
"&00N60000001VNP1=http://www.xxx.com/player/xxxxxx/videoPlayer.html";
// Send Data to SFDC
sPostToURL = sPostToURL + sPostData;
String myWebReturn = MakeWebRequest(sPostToURL, "");
Response.Write("status=sent");
}
}
protected string MakeWebRequest(string url, String webProxyServer)
{
string returnData = String.Empty;
WebRequest request = WebRequest.Create(url);
if (webProxyServer.Trim().Length > 0)
{
request.Proxy = GetWebProxy(webProxyServer);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
Stream data = response.GetResponseStream();
StreamReader reader = new StreamReader(data);
returnData = reader.ReadToEnd();
}
else
{
Console.WriteLine("Error making WebRequest for url: " + url);
}
return returnData;
}
protected IWebProxy GetWebProxy(String webProxyServer)
{
string webProxyAddress = null;
try
{
webProxyAddress = webProxyServer;
if (webProxyAddress != null)
{
webProxyAddress = webProxyAddress.Trim();
if (webProxyAddress == String.Empty)
{
webProxyAddress = null;
}
}
}
catch (Exception)
{
// Any exception ==> no proxy: the COM interop often throw an exception for the case of no proxy server!
webProxyAddress = null;
}
//Initialize to no proxy
//IWebProxy iwebProxy = GlobalProxySelection.GetEmptyWebProxy();
IWebProxy webProxy = WebRequest.DefaultWebProxy;
if (webProxyAddress != null)
{
webProxy = new WebProxy(webProxyAddress);
}
return webProxy;
}
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE