Hey all,
I see in the API that we can create contacts, which works great. But how do I create a group of contacts? I can't find anything referencing groups of contacts except for a bool value when getting a list of contacts through AJAX. Which for some weird reason, I have to do an AJAX login call on a freshly created account to be able to add contacts.
Thanks in advance,
Ed
Programatically creating contact groups?
I found a way to do it. It's not documented, infact, there's a lot not documented with the API and .net. Took a while to figure it out, but, hopefully this will help someone.
And to add a contact to the group....
I don't know if the groups.UpdateGroup line is required, but it works for me.[/quote]
Code: Select all
MailEnable.MailboxContact.ContactGroup group = new MailEnable.MailboxContact.ContactGroup();
MailEnable.MailboxContact.ContactGroups groups = new MailEnable.MailboxContact.ContactGroups();
string newName = groupName.Replace("'", "");
groups.Postoffice = "postoffice";
groups.UserName = "mailbox";
group = groups.AddGroup(newName);
//these next few lines are because if you dont do this, it will overwrite the currently existing groups...weird
group = new MailEnable.MailboxContact.ContactGroup();
group.Postoffice = _mailBox.Postoffice;
group.UserName = _mailBox.MailboxName;
group.GroupName = newName;
bool myResult = group.FetchByName();
if (!myResult) { Console.WriteLine("Unable to create and load group."); }
Code: Select all
int result = group.AddMember(storeItem.StoreItem_GetProperty("ME_ITEM_ID", string.Empty));
if (result != 0) { Console.WriteLine("Unable to add."); }
bool outter = groups.UpdateGroup(group.ListID, group.GroupName, group.GetMemberAddressIDList());
if (!outter) { Console.WriteLine("Unable to save group."); }