06-04-2013 04:53 AM
I am trying to programatically create documents using WriteOther from within a plugin, but using a contact other than the ApplicationState.CurrentContact. I have passed the actApp to the plugin, so have access to all I would have as my current logged in user. delContact is the new delivery Contact (different to the current contact).
MsgBox(actApp.ApplicationState.CurrentContact.FullName) 'Mr. Smith actApp.ApplicationState.CurrentContact = delContact 'delContact = Mr. Jones MsgBox(actApp.ApplicationState.CurrentContact.FullName) 'Mr. Jones Dim UIcm As UICorrespondenceManager = actApp.UICorrespondenceManager UIcm.WriteOther("templateDocumentName") UIcm.Dispose()
This reports the initial CurrentContact.FullName (Mr. Smith), and after the assignment reports the newly assigned CurrentContact.FullName (Mr. Jones).
However the document still mailmerges with the original contact details for Mr. Smith.
What do I have to do to trigger use of Mr. Jones's contact details in the mail merge?
06-04-2013 06:58 AM
Incidentally, although I can use UIcm.WriteOther(delContact) to do a mailmerge with the contact I want, this does not allow me to programatically set the template.
What would be ideal would be:
Any help appreciated.
06-04-2013 01:30 PM
06-06-2013 07:59 AM
Sorry, I tried that (as my example showed).
I have just found the solution. Apparently the WriteOther uses the CurrentContactList, with the only entry being the current contact.
So, when I add the following, it works!
Thanks for looking.