Re: [Evolution-hackers] Adding an email address to an EContact



On Mon, 2005-05-02 at 14:23 -0400, Tom Copeland wrote:
> Howdy -
> 
> I'm trying to write some C that adds an email address to an existing
> EContact; here's what I've got:
> 
> EContact* ev_contact = E_CONTACT(get_contact());
> EVCardAttribute* attr = e_vcard_attribute_new (NULL, EVC_EMAIL);
> e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_TYPE), "WORK");
> e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_X_DEST_EMAIL), "tom foo bar");
> GList* email_attrs = g_list_append(NULL, attr);
> e_contact_set_attributes (ev_contact, E_CONTACT_EMAIL, email_attrs)
> 
> That doesn't seem to do the trick, though... I must be doing something
> wrong.  I've looked around the source code for a bit but I only seem to
> be able to find examples of importing via the VCard format.  

You should add the address with

e_vcard_attribute_add_value (attr, "tom foo bar");

Also remember that you have to commit the contact for it to be stored
back in the address book.

If you need code to look at, I think the best place to look would be in
Evolution proper:

evolution/addressbook/gui/contact-editor/e-contact-editor.c

-- 
Hans Petter Jansson | <hpj novell com>
Evolution Developer | http://hp.cl.no/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]