Working with the ACT! framework is an interesting experience. The code is very verbose and requires some expertise to understand. And it took me a while to realize that the best way to retrieve data is through the database, while using the framework to perform the updates.
The following method writes an email history to the database. It is useful for when you need to record automated processes to groups in the database.
The method takes a GUID as an argument, primarily because there are no unique naming constraints in the group list.
using Act.Framework;using Act.Framework.Contacts;using Act.Framework.Groups;using Act.Framework.Histories;using Act.Framework.Lookups;using Act.Shared.Collections;// simplified connection for multiple methodsprivateActFramework actFramework() {string cn = ConfigurationManager.ConnectionStrings["actDb"].ConnectionString;
string login = ConfigurationManager.AppSettings["actLogin"].ToString();
string pwd = ConfigurationManager.AppSettings["actPwd"].ToString();
ActFramework f = newActFramework();f.LogOn(cn, login, pwd);
return f;}
// adds email history to the databasepublic void AddEmailGroupHistory(string GUID, string subject, string body) {
// create a disposable connection to the database using(ActFramework f = actFramework()) { // create a new group GUID array with one elementGuid[] gGuid = new Guid[] { new Guid(GUID) };
// get a group list - the list will contain one groupGroupList gList = f.Groups.GetGroupsByID(null, gGuid); // get a contact list from the first group in the listContactList cList = gList[0].GetContacts(null); // creates an all-zero GUIDGuid activityClearedId = Guid.Empty;
// creates a system type of Email sentHistoryType hType = new HistoryType(SystemHistoryType.EmailSent); // the history is publicbool isPrivate = false;
// start and emd (duration) are equalDateTime startEnd = DateTime.Now;
// Create a new history objectHistory h = f.Histories.CreateHistory(cList, gList, activityClearedId,
hType, isPrivate, startEnd, startEnd, subject, body);
// commit the history to the databaseh.Update();
}
}