WS newEmailMailing(WithReply) incomplete template copy

Use this forum to report bugs and to check for bugfixes and new releases of OpenEMM

Moderator: moderator

mkalen
Posts: 33
Joined: Tue Jan 20, 2009 7:51 pm

WS newEmailMailing(WithReply) incomplete template copy

Post by mkalen »

Greetings all,
I have a question about the WebService functions newEmailMailing and newEmailMailingWithReply.

I want to do the following:
  • Create templates in OpenEMM
  • Upload picture components to the templates
  • Manage link tracking of the templates
  • Use WebService/SOAP to automatically create a number of mailings with the newEmailMailing function
  • Automatic delivery of new mailings through WebService sendMailing-calls
When creating a mailing from a template with the WebService, I would expect that the uploaded picture components and link tracking settings from the template would be used for the new mailing.

Since I want to automate the process I want to get rid of any manual steps required for sending the mailing.

I have looked a bit at the implementing code of the WebService, focusing on the org.agnitas.webservice.EmmWebservice class. Both newEmailMailing and newEmailMailingWithReply use the "loadTemplate" function to copy values from the template to the mailing.

Would it not be better if the loadTemplate function also copied TrackableLinks and components other than agnText/agnHtml (i.e. uploaded files etc) to the new mailing?

I would like to discuss this with other users and the OpenEMM team. What do you think? Does it make sense?

I have some (untested) example replacement code for a new loadTemplate function:

Code: Select all

    private Mailing loadTemplate(Mailing aMailing, MailingDao mDao, ApplicationContext con) {
		Mailing tmpMailing=(Mailing) con.getBean("Mailing");
    	MailingComponent tmpComp=null;
    	String htmlCompName=null;
    	String textCompName=null;
    	tmpMailing = mDao.getMailing(aMailing.getMailTemplateID(), aMailing.getCompanyID());

    	if(tmpMailing != null) {
    		aMailing.setMailingType(tmpMailing.getMailingType());
    		aMailing.setMailinglistID(tmpMailing.getMailinglistID());
    		aMailing.setTargetMode(tmpMailing.getTargetMode());
    		aMailing.setTargetGroups(tmpMailing.getTargetGroups());
    		aMailing.setMediatypes(tmpMailing.getMediatypes());
    		aMailing.setArchived(tmpMailing.getArchived());
    		aMailing.setCampaignID(tmpMailing.getCampaignID());

            // load template for this mailing
            if((tmpComp = tmpMailing.getHtmlTemplate()) != null) {
            	htmlCompName = tmpComp.getComponentName();
            	aMailing.setHtmlTemplate(tmpComp);
            }
            if((tmpComp = tmpMailing.getTextTemplate()) != null) {
            	textCompName = tmpComp.getComponentName();
            	aMailing.setTextTemplate(tmpComp);
            }
        	Map tmpComponents = tmpMailing.getComponents();
        	if (tmpComponents != null) {
        		Iterator tmpComponentIter = tmpComponents.entrySet().iterator();
        		while (tmpComponentIter.hasNext()) {
        			Map.Entry entry = (Map.Entry) tmpComponentIter.next();
        			String name = (String) entry.getKey();
        			if (!name.equals(htmlCompName) && !name.equals(textCompName)) {
        				tmpComp = (MailingComponent) entry.getValue();
        				aMailing.addComponent(tmpComp);
        			}
        		}
        	}

        	aMailing.setMediatypes(tmpMailing.getMediatypes());
        	aMailing.setTrackableLinks(tmpMailing.getTrackableLinks());
    	}
		return aMailing;
	}
mkalen
Posts: 33
Joined: Tue Jan 20, 2009 7:51 pm

Re: WS newEmailMailing(WithReply) incomplete template copy

Post by mkalen »

mkalen wrote: Would it not be better if the loadTemplate function also copied TrackableLinks and components other than agnText/agnHtml (i.e. uploaded files etc) to the new mailing?
This is already fixed with the issue 2545398.

By using the clone() method of the Mailing bean, all trackable links and every component will be copied from the template.

Thanks!
Post Reply