AnsweredAssumed Answered

How can I transmit information from a .ascx form to Sugar using SOAP?

Question asked by Savage75 Savage75 on Feb 20, 2014
Latest reply on May 9, 2014 by amusarra amusarra
Hello there,
i need help to get the information from contact form on Umbraco contact.ascx to SugarCrm using Sugar's SOAP API ? 

my contactform.ascx.cs below:

using System;
using System.Text;
using System.Web.UI;
using umbraco;

namespace BmwUMB.usercontrols
{
    public partial class ContactForm : System.Web.UI.UserControl
    {
        public int ThankYouPage { get; set; }
        public string Subject { get; set; }
        public string EmailTo { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            Page.MaintainScrollPositionOnPostBack = true;
        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                // Quick check for mandatory fields
                if (string.IsNullOrWhiteSpace(tbEpost.Text) | string.IsNullOrWhiteSpace(tbNamn.Text) | string.IsNullOrWhiteSpace(tbOrt.Text) | string.IsNullOrWhiteSpace(tbTelefonnummer.Text))
                {
                    // Found an empty field, return error
                    if (tbEmail.Text == "") { tbEmail.CssClass = "error"; } else { tbEmail.CssClass = ""; }
                    if (tbName.Text == "") { tbName.CssClass = "error"; } else { tbName.CssClass = ""; }
                    if (tbCity.Text == "") { tbCity.CssClass = "error"; } else { tbCity.CssClass = ""; }
                    if (tbTele.Text == "") { tbTele.CssClass = "error"; } else { tbTele.CssClass = ""; }
                    return;
                }
                // No errors create email
                var email = new StringBuilder();
                email.AppendFormat("<table><tr><td><p>Name: " + tbName.Text + "</p></td></tr>");
                email.AppendFormat("<tr><td><p>Company: " + tbCompany.Text + "</p></td></tr>");
                email.AppendFormat("<tr><td><p>Email: " + tbemail.Text + "</p></td></tr>");
                email.AppendFormat("<tr><td><p>Tele: " + tbTele.Text + "</p></td></tr>");
                email.AppendFormat("<tr><td><p>City: " + tbCity.Text + "</p></td></tr>");
                email.AppendFormat("<tr><td><p>Product: " + ddlProduct.SelectedItem.Text + "</p></td></tr>");
                email.AppendFormat("<tr><td><p>Message: " + tbMessage.Text + "</p></td></tr>");
                if (cbNews.Checked == true)
                {
                    email.AppendFormat("<tr><td><p>I need to have news</p></td></tr>");
                }

                email.AppendFormat("</table>");

                // Send the email
                library.SendMail(EmailTo, EmailTo, Subject, email.ToString(), true);

                // Redirect to thank you page
                Response.Redirect(library.NiceUrl(ThankYouPage));
            }
            catch (Exception ex) { Response.Write(ex.ToString()); }
        }
    }
}

Can somebody help me on this.

Thanks in advance.

Outcomes