Attaching a Bcc email from Subscription Renewal to Maximizer Company documents

From LeonWiki!

Jump to: navigation, search
  • Identify appropriate com4j interface to use (ILetters)
  • Construct the arrays needed for attachments in the constructor
	public MaximizerDatabase()
	{
		BufferedInputStream bis = null;
		PropertyConfigurator.configure("./logging/log4j.properties");
		this.logger   = Logger.getLogger("MaximizerDatabase");
		this.logger.setLevel(Level.DEBUG);
		this.cIds[0]  = new String("logo");
		this.names[0] = new String("Symmetry Solutions Logo");
		
		try {
			bis = new BufferedInputStream(MaximizerDatabase.class.getResourceAsStream("..\\..\\..\\sym_logo_small.gif"));
			int i = bis.read(this.mybites);
			this.myIntOffsets[0] = i;
		} catch(Exception e) {
			logger.debug("Exception: msg = "+e.getMessage());
		}	
	}
	
	
  • The HashMap parameter 'map' has been filled in by the calling module and contains all the email configuration information
	public boolean attachEmailDocument(HashMap map)
	{
		Date dt = new Date();
		Com4jObject obj = getObject("Letters");
		ILetters iLetters = obj.queryInterface(ILetters.class);
		boolean result = false;
		
		try {			
			logger.debug("calling iLetters.addEmailDocument");
			result = iLetters.addEmailDocument
			(
				(String)map.get("clientId"), 
				0, 					//contact number
				fromDate(dt),		//using current date
				(String)map.get("from"), 
				(String)map.get("to"),
				(String)map.get("cc"), 
				(String)map.get("bcc"), 
				(String)map.get("subject"),
				(String)map.get("body"), 
				true, 				//isHtml
				1, 					//priority
				this.mybites, 		//attachment, 
				this.myIntOffsets, 	//offsets, 
				this.names, 		//attachName, 
				this.cIds 			//attachCID
			);
			logger.debug("result = " + result);
		}
		catch (Exception e) {
			logger.debug("Exception: msg = "+e.getMessage());
		}
		return result;
	}

Personal tools
Alchemy Software, Inc.
Alchemy Software Website