Community
Showing results for 
Search instead for 
Do you mean 
Reply

some C# code you may find useful: add a note, list contacts, login NO WARRANTIES but good luck

Copper Contributor
Posts: 12
Country: United States

some C# code you may find useful: add a note, list contacts, login NO WARRANTIES but good luck

// add a note public void addnote(Contact cContact, string sText ) { try { NoteType nType; nType = new NoteType(SystemNoteType.Note); ActFwk.Notes.CreateNote(nType, sText, System.DateTime.Now, false, cContact); } catch (Exception ex) { string s = ex.ToString(); } } // get a contact value //usage: string sphone = getcontactval(cContact, "TBL_CONTACT.BUSINESS_PHONE"); public string getcontactval(Contact c, string fieldname) { object o = c.ContactFields[fieldname, true]; if (o != null ) return o.ToString(); else return ""; } public void getcontacts(string padfile, string user, string password, string stype ) { if (!LoginToACTDatabase(padfile, user, password)) return; conn.Open(); ContactList cList = ActFwk.Contacts.GetContacts(null); for (int i = 0; i < cList.Count; i++) { string sphone = ""; string scontact = ""; string scompany = ""; string sfullname = ""; string szip = ""; string sweb = ""; string scountry = ""; string saddress = ""; string scity = ""; string sstate = ""; string sfirstname = ""; string slastname = ""; string semail=""; string sact = ""; string stitle=""; Contact c = cList[i]; if( c.Company != null ) scompany = c.Company; object oa=c.Fields["Contact.Account Executive", false]; if (oa != null) sact = oa.ToString(); sphone = getcontactval(c, "TBL_CONTACT.BUSINESS_PHONE"); szip = getcontactval(c, "TBL_CONTACT.BUSINESS_POSTALCODE"); stitle=getcontactval(c,"TBL_CONTACT.JOBTITLE"); sweb = getcontactval(c, "TBL_CONTACT.CONTACTWEBADDRESS"); saddress=limit(getcontactval(c,"TBL_CONTACT.BUSINESS_LINE1" )),80; sstate = getcontactval(c, "TBL_CONTACT.BUSINESS_STATE")); scity = limit(getcontactval(c, "TBL_CONTACT.BUSINESS_CITY")),50; object of = c.FirstName; if (of != null ) sfirstname = of.ToString(); object ol = c.LastName; if (ol != null ) slastname = ol.ToString(); object oname = c.FullName; if (oname != null) sfullname = oname.ToString(); semail = getcontactval(c, "TBL_CONTACT.BUSINESS_EMAIL"); // at this point you have the basic info from a contact } ActFwk.LogOff(); conn.Close(); } public bool LoginToACTDatabase(string sPADFilePath, string sActUserName, string sUserPassword ) { try { ActFwk.LogOn(sPADFilePath, sActUserName, sUserPassword); } catch (Exception er) { Application.Exit(); return false; } return true; } //LoginToACTDatabase public string limit(string val, int len) { if (val.Length > len) return val.Substring(0, len); else return val; }

 

New Member
Posts: 4
Country: Taiwan

Re: some C# code you may find useful: add a note, list contacts, login NO WARRANTIES but good luck

But ....

How can I get Notes Info?!