working on it ...

Filters

Explore Public Snippets

Sort by

Found 4,410 snippets matching: contact

    public by cghersi @ MailUp API DEV  206859  8  6  1

    MailUp REST API - How to subscribe to a particular list several contacts with the "Confirmed Optin" Procedure

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void SubcribeRecipientsWithDoubleOptin(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Subscribe recipients:
        int idList = 1;
        List<ConsoleRecipientItem> recipients = new List<ConsoleRecipientItem>();
        ConsoleRecipientItem recipient1 = new ConsoleRecipientItem()
        {
            Email = "test1@mailup.com",
            Name = "First New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3331234567",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        ConsoleRecipientItem recipient2 = new ConsoleRecipientItem()
        {
            Email = "test2@mailup.com",
            Name = "Second New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3337654321",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name2_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName2_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        recipients.Add(recipient1);
        recipients.Add(recipient2);
        int subscriptionResult = 0;
        try
        {
            subscriptionResult = client.AddRecipientsToList(idList, recipients, true);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 2.1) wait for the end of import task:
        if (subscriptionResult > 0)
        {
            Console.WriteLine("Recipients Import started; import ID:" + subscriptionResult);
    
            //optionally we can check the import status:
            bool completed = false;
            do
            {
                ConsoleImportStatus importStatus = client.CheckImportStatus(subscriptionResult);
                if (importStatus == null)
                {
                    Console.WriteLine("Cannot check the import status for import task #" + subscriptionResult);
                    return;
                }
                completed = importStatus.Completed;
            } while (!completed);
            Console.WriteLine("Recipients Added!");
        }
        else
        {
            Console.WriteLine("An error occurred while adding the recipients.");
            return;
        }
    
        // 3) Retrieve the sendingID of the confirmation email related to the previous task:
        int sendingID = -1;
        try
        {
            sendingID = client.GetSendingIDForImport(subscriptionResult);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot retrieve sending ID due to " + ex.Message);
            return;
        }
        if (sendingID <= 0)
        {
            Console.WriteLine("Cannot retrieve sending ID.");
            return;
        }
    
        // 4) Send the confirmation email:
        EmailSendingItem sendingResult = null;
        try
        {
            sendingResult = client.SendEmailMessage(sendingID);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot send email due to " + ex.Message);
            return;
        }
        if (sendingResult == null)
            Console.WriteLine("Cannot send confirmation email.");
        else
            Console.WriteLine("Confirmation email sent!");
    }
                

    public by cghersi @ MailUp API DEV  1323  26  7  0

    MailUp REST API - How to subscribe to a particular list several contacts with some information like email, mobile number, etc.

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void SubcribeRecipients(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Prepare the input:
        int idList = 1;
        List<ConsoleRecipientItem> recipients = new List<ConsoleRecipientItem>();
        ConsoleRecipientItem recipient1 = new ConsoleRecipientItem()
        {
            Email = "test1@mailup.com",
            Name = "First New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3331234567",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        ConsoleRecipientItem recipient2 = new ConsoleRecipientItem()
        {
            Email = "test2@mailup.com",
            Name = "Second New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3337654321",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name2_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName2_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        recipients.Add(recipient1);
        recipients.Add(recipient2);
    
        // 3) Invoke the web method:
        int result = 0;
        try
        {
            result = client.AddRecipientsToList(idList, recipients);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 4) Print results:
        if (result > 0)
        {
            Console.WriteLine("Recipients Import started; import ID:" + result);
    
            //optionally we can check the import status:
            bool completed = false;
            do
            {
                ConsoleImportStatus importStatus = client.CheckImportStatus(result);
                if (importStatus == null)
                {
                    Console.WriteLine("Cannot check the import status for import task #" + result);
                    return;
                }
                completed = importStatus.Completed;
            } while (!completed);
            Console.WriteLine("Recipients Added!");
        }
        else
            Console.WriteLine("An error occurred while adding the recipients.");
    }
    

    public by cghersi @ MailUp API DEV  1593  16  6  0

    MailUp REST API - How to subscribe a single contact with the "Confirmed Optin" Procedure

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void SubscribeContactWithCOI(string clientID, string clientSecret, string username, string password)
    {
      // 1) Setup the MailUp Client:
      MailUpClient client = new MailUpClient(clientID, clientSecret);
      try
      {
        client.RetrieveAccessToken(username, password);
      }
      catch (MailUpException ex)
      {
        Console.WriteLine("Unable to access the service due to " + ex.Message);
        return;
      }
    
      // 2) Prepare the input:
      int idList = 1;
      ConsoleRecipientItem recipient = new ConsoleRecipientItem()
      {
        Email = "test1COI@mailup.com",
        Name = "First COI New Recipient" + DateTime.Now.ToFileTimeUtc(),
        Fields = new List<ConsoleRecipientDynamicFieldItem>()
        {
            new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1COI_" + DateTime.Now.ToFileTimeUtc() },
            new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1COI_" + DateTime.Now.ToFileTimeUtc() }
            //here you can add all the fields you want to add...
        }
      };
    
      // 3) Invoke the web method:
      int result = 0;
      try
      {
        result = client.AddRecipientToList(idList, recipient, true);
      }
      catch (Exception ex)
      {
        Console.WriteLine("Cannot perform the operation due to " + ex.Message);
        return;
      }
    
      // 4) Print results:
      if (result > 0)
        Console.WriteLine("Recipients Added with confirmed Opt-in! The ID of the recipient is " + result);
      else
        Console.WriteLine("An error occurred while adding the recipients with confirmed Opt-in.");
    }
                

    public by Thomas Callahan  8855  4  3  0

    Contact Editor using KnockoutJS

    Contact Editor using KnockoutJS: ContactKnockout.html
            lastName: "",
            phones: ko.observableArray()
          });
        };
    
        self.removeContact = function(contact)
        {
          self.contacts.remove(contact);
        };
    
        self.addPhone = function(contact)
        {
          contact.phones.push(
          {
            type: "",
            number: ""
          });
        };
    
        self.removePhone = function(phone)
        {
          $.each(self.contacts(), function()
          {
            this.phones.remove(phone)
          })
        };
    
        self.save = function()
        {
          self.lastSavedJson(JSON.stringify(ko.toJS(self.contacts), null, 2));
        };
    
        self.lastSavedJson = ko.observable("")
      };
    
      ko.applyBindings(new ContactsModel(initialData));
      </script>
    
    </body>
    
    </html>
    
    

    public by DanteNex  3258  3  7  1

    Script PHP para enviar email usando PHPMailer.

    Exemplo de script usado para enviar email utilizando a biblioteca PHPMailer, perfeito para formulários de contato.
    <?php 
    include "phpmailer/class.phpmailer.php";
    date_default_timezone_set("America/Sao_Paulo");
    $nome = $_POST['nome'];
    $email = $_POST['email'];
    $assunto = $_POST['assunto'];
    $mensagem = $_POST['mensagem'];
    
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->CharSet = 'UTF-8';
    
    $mail->Host       = "smtp.gmail.com";
    $mail->SMTPDebug  = 0;
    $mail->SMTPAuth   = true;
    $mail->SMTPSecure = "tls";
    $mail->Port       = 587;
    $mail->Username   = "xxx@xxxxxx.com.br";
    $mail->Password   = "xxxxxx";
    
    $mail->From = 'xxx@xxxxxx.com.br';
    $mail->FromName = "Nome";
    $mail->AddReplyTo("xxx@xxxxxx.com.br","Nome");
    $mail->IsHTML(true);
    
    $textbody = "Email enviado pelo formulario de contato do site XXXX: <br/>".
    "Nome: $nome <br/>".
    "Email: $email <br/>".
    "Assunto: $assunto <br/>".
    "Mensagem: $mensagem <br/>".
    "Data: " . date("d-m-Y h:i:sa").
    "<hr/>".
    "<em> Seu Site - &copy; " . date("Y") . "</em>";
    
    
    $mail->Subject    = $assunto;
    $mail->AltBody    = $textbody;
    $mail->MsgHTML($textbody);
    $mail->AddAddress("xxx@xxxxxx.com.br");
    
    if($mail->Send()) {
    	header("Location: contato_status.php?status=1");
    	} else{
    	header("Location: contato_status.php?status=0");
    	
    }
    
    
    
    
    
    ?>            

    public by cghersi  5834  1  8  3

    How to retrieve GMail contacts via API, using OAuth2 token and not username/password credentials

    This class takes charge of the interaction with Google Contacts API, authenticating with an AccessToken authorization flow. In this way the final user should type the credentials in the Google form and not in your form. The "token" parameter of GetContacts() method is the one sent by Google to the callback url specified in the static constant "s_
    using System;
    using System.Linq;
    using System.Collections.Generic;
    using Google.Contacts;
    using Google.GData.Contacts;
    using Google.GData.Client;
    using Google.GData.Extensions;
    
    namespace Contact.Utils
    {
      /// <summary>
      /// Summary description for GmailHelper
      /// </summary>
      public class GmailHelper
      {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    
        private static fastJSON.JSON jsonUtils = EntityUtils.InitJSONUtils();
    
        private static readonly string APP_NAME = "my app name";
        private static readonly string s_ClientId = "client id given by Google";
        private static readonly string s_ClientSecret = "secret given by Google;
        private static readonly string s_accessTokenUrl = "https://accounts.google.com/o/oauth2/token";
        private static readonly string s_redirUri = WebConfig.Current.PublicPath + "User/GmailCallback";
    
        #region PUBLIC API
        //////////////////////////////////////////////////////////////////////////////////////////////////////
    
        public static string GetRedirUriForContacts()
        {
          return string.Format("https://accounts.google.com/o/oauth2/auth?scope=https://www.google.com/m8/feeds&redirect_uri={0}&response_type=code&client_id={1}",
            s_redirUri, s_ClientId);
        }
    
        public static List<SimpleContact> GetContacts(string token)
        {
          List<SimpleContact> results = new List<SimpleContact>();
    
          //exchange the code for a token:
          string postData = string.Format("code={0}&client_id={1}&client_secret={2}&redirect_uri={3}&grant_type=authorization_code",
            token, s_ClientId, s_ClientSecret, s_redirUri);
          string accessTokenResp = Utilities.SendHttpRequest(s_accessTokenUrl, postData, true);
          if (string.IsNullOrEmpty(accessTokenResp))
            return results;
    
          AccessTokenStruct parsedJson = null;
          try
          {
            parsedJson = jsonUtils.ToObject<AccessTokenStruct>(accessTokenResp); 
          }
          catch (Exception e)
          {
            log.ErrorFormat("Cannot deserialize access token response: '{0}' due to {1}", accessTokenResp, e.Message);
            return results;
          }
          if (parsedJson == null)
            return results;
    
          //ask for contacts:
          RequestSettings settings = new RequestSettings(APP_NAME, parsedJson.access_token); 
          settings.AutoPaging = true;
          ContactsRequest cr = new ContactsRequest(settings);
          Feed<Contact> contactsFeed = cr.GetContacts();
          IEnumerable<Contact> contacts = null;
          if (contactsFeed != null)
            contacts = contactsFeed.Entries;
          if (contacts == null)
            return results;
    
          try
          {
            foreach (SimpleContact c in contacts)
            {
              if (c.PrimaryEmail == null)
                continue;
              string preferredEmail = c.PrimaryEmail.Address;
              if (string.IsNullOrEmpty(preferredEmail))
                continue;
              string[] otherEmails = null;
              if (c.Emails != null)
                otherEmails = c.Emails.Select(e => e.Address).ToArray();
              S2CContact contact = new S2CContact((c.Name == null ? "" : c.Name.FullName), 
                                                  preferredEmail, otherEmails);
              results.Add(contact);
            }
          }
          catch (Exception e)
          {
            log.ErrorFormat("Cannot retrieve contacts due to {0}", e.Message);
            return results;
          }
    
          return results;
        }
    
        #endregion
        //////////////////////////////////////////////////////////////////////////////////////////////////////
      }
    
      public class AccessTokenStruct
      {
        public string access_token { get; set; }
        public int expires_in { get; set; }
        public string token_type { get; set; }
    
        public AccessTokenStruct() { }
      }
    
      public class SimpleContact
      {
        public string PreferredEmail { get; set; }
        public string Name { get; set; }
        public string[] Emails { get; set; }
    
        public SimpleContact(string name, string preferredEmail, string[] emails = null)
        {
          Name = name;
          PreferredEmail = preferredEmail;
          if (emails == null)
            Emails = new string[] { preferredEmail };
          else
          {
            List<string> allEmails = new List<string>(emails);
            allEmails.Add(preferredEmail);
            Emails = allEmails.Distinct().ToArray();
          }
        }
    
        public override string ToString()
        {
          if (string.IsNullOrEmpty(Name))
            return PreferredEmail;
          else
            return string.Format("{0} [{1}]", Name, PreferredEmail);
        }
      }
    
    }            

    public by p.kontalis  1966  2  5  0

    Contacts Export from VTiger to Google Contacts

    SELECT 
    REPLACE (REPLACE (accountname, '"', '_'), ',', '_') AS 'Name',
    REPLACE (REPLACE (accountname, '"', '_'), ',', '_') AS 'Given Name',
    '' AS 'Additional Name',
    '' AS 'Family Name',
    '' AS 'Yomi Name',
    '' AS 'Given Name Yomi',
    '' AS 'Additional Name Yomi',
    '' AS 'Family Name Yomi',
    '' AS 'Name Prefix',
    '' AS 'Name Suffix',
    '' AS 'Initials',
    '' AS 'Nickname',
    '' AS 'Short Name',
    '' AS 'Maiden Name',
    '' AS 'Birthday',
    '' AS 'Gender',
    '' AS 'Location',
    '' AS 'Billing Information',
    '' AS 'Directory Server',
    '' AS 'Mileage',
    '' AS 'Occupation',
    '' AS 'Hobby',
    '' AS 'Sensitivity',
    '' AS 'Priority',
    '' AS 'Subject',
    '' AS 'Notes',
    '* My Contacts' AS 'Group Membership',
    '* Work' AS 'E-mail 1 - Type',
    REPLACE (REPLACE (email1, '"', '_'), ',', '_') AS 'E-mail 1 - Value',
    'Εργασία 2' AS 'E-mail 2 - Type',
    REPLACE (REPLACE (email2, '"', '_'), ',', '_') AS 'E-mail 2 - Value',
    'Εργασία 2' AS 'Phone 1 - Type',
    REPLACE (REPLACE (phone, '"', '_'), ',', '_') AS 'Phone 1 - Value',
    'Work' AS 'Phone 2 - Type',
    REPLACE (REPLACE (otherphone, '"', '_'), ',', '_') AS 'Phone 2 - Value',
    'Fax' AS 'Phone3 - Type',
    REPLACE (REPLACE (fax, '"', '_'), ',', '_') AS 'Phone 3 - Value',
    'Home' AS 'Address 1 - Type',
    CONCAT('"',bill_street,'\n',bill_city,bill_state,' ',bill_pobox,'\n',bill_country,'"') AS 'Address 1 - Formatted',
    REPLACE (REPLACE (bill_street, '"', '_'), ',', '_') AS 'Address 1 - Street',
    REPLACE (REPLACE (bill_city, '"', '_'), ',', '_') AS 'Address 1 - City',
    '' AS 'Address 1 - PO Box',
    REPLACE (REPLACE (bill_state, '"', '_'), ',', '_') AS 'Address 1 - Region',
    REPLACE (REPLACE (bill_pobox, '"', '_'), ',', '_') AS 'Address 1 - Postal Code',
    REPLACE (REPLACE (bill_country, '"', '_'), ',', '_') AS 'Address 1 - Country',
    '' AS 'Address 1 - Extended Address',
    'Home Page' AS 'Website 1 - Type',
    REPLACE (REPLACE (website, '"', '_'), ',', '_') AS 'Website 1 - Value'
    FROM vtigercrm600.vtiger_account
    LEFT JOIN vtigercrm600.vtiger_accountbillads
    ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid;
    # NOTE: - After the execution click on export button and save it as csv
    # NOTE: The " and , have been replaced by _    
    # NOTE: If you want to use this snippet, consider to change the "vtigercrm600" with your database name. ;)
    

    public by estudijoanpuig  319  0  3  0

    formulari de contacte i php

    formulari de contacte i php: formcontacte_action_tot1.php
     <?php
    if(isset($_POST['contactSubmit'])){
    	$message = " ";
    	$fullName = $_POST["fullName"] ;
    	$email = $_POST["email"];
    	$formMessage = $_POST["message"];
    	
    	
    	$message .= "Full Name: " . $fullName . "\
    ";
    	$message .= "Email Address: " . $email . "\
    ";
    	$message .= "Comment: " . $formMessage . "\
    ";
    	
    	$subject = "Contact Us";
    	$myEmail ="joanpuigbertran@hotmail.com";
    	
    	if (mail($myEmail, $subject, $message)){
    		$success = "missatge enviat correctament";
    	}else{
    		$success = "Message Sending Failed, try again";
    	}
    }
    ?>
    <?php
    if (isset($success)){ echo "<div class='alert alert-success' role='alert'>" . $success . "</div>";}
    ?>
    	<form  method="post" action="" id="contactForm">
    	
    		<div class="form-group">
    			<input type="text" name="fullName" id="fullName" required="required" placeholder="nom i cognoms" class="form-control"/>
    		</div>
    						
    		<div class="form-group">
    			
    			<input class="form-control"type="email" name="email" id="email" required="required" placeholder="email" />
    		</div>
    					
    		<div class="form-group">
    			
    			<textarea class="form-control"placeholder="el teu missatge"name="message" id="message" rows="2" cols="30"></textarea>
    		</div>
    					
    		<div class="submit form-group">
    			<input class="col-md-4 control-label btn-block"type="submit" name="contactSubmit" id="contactSubmit" value="Send Message" />
    		</div>
    		
    	</form>
    
    

    public by cghersi  4783  1  6  1

    Remove Duplicate rows in SQL Server

    This script removes the duplicate rows in table Customers detecting the rows with the same contactname
    SET NOCOUNT ON
    SET ROWCOUNT 1
    WHILE 1 = 1
      BEGIN
        DELETE  
        FROM Customers
        WHERE contactname IN
            (SELECT  contactname
             FROM    Customers
             GROUP BY contactname
             HAVING  COUNT(*) > 1)
          
        IF @@Rowcount = 0
          BREAK ;
     END
     SET ROWCOUNT 0          

    public by Zenitram.PRO  5020  15  6  1

    Linear search in an Array.

    Finding that Special Someone Let's say we're looking for someone in our address book with a specific last name. We can do this with a technique for searching arrays called "linear search". With it, we use a loop to check through all of the items in the array one-by-one until we see the item that we want. We can apply linear search to print
    var bob = {
        firstName: "Bob",
        lastName: "Jones",
        phoneNumber: "(650) 777-7777",
        email: "bob.jones@example.com"
    };
    
    var mary = {
        firstName: "Mary",
        lastName: "Johnson",
        phoneNumber: "(650) 888-8888",
        email: "mary.johnson@example.com"
    };
    
    var contacts = [bob, mary];
    
    function printPerson(person) {
        console.log(person.firstName + " " + person.lastName);
    }
    
    function list() {
    	var contactsLength = contacts.length;
    	for (var i = 0; i < contactsLength; i++) {
    		printPerson(contacts[i]);
    	}
    }
    
    /*Create a search function
    then call it passing "Jones"*/
    function search(lastName)
    {
        contactsLength = contacts.length;
    	for (var i = 0; i < contactsLength; i++) 
    	{
    	    if (lastName === contacts[i]["lastName"])
    	    {
    	        printPerson(contacts[i]);
    	    }
    	}
    }
    
    search("Jones");                                    
    • Public Snippets
    • Channels Snippets