upload a file to salesforce using connector - java

i builded a flow in mule which create a case in Salesforce using 'Salesforce' connector. now i need to upload a file to that case using the same mule flow. This can be done programatically by the following code:
try {
File f = new File("c:\java\test.docx");
InputStream is = new FileInputStream(f);
byte[] inbuff = new byte[(int)f.length()];
is.read(inbuff);
Attachment attach = new Attachment();
attach.setBody(inbuff);
attach.setName("test.docx");
attach.setIsPrivate(false);
// attach to an object in SFDC
attach.setParentId("a0f600000008Q4f");
SaveResult sr = binding.create(new com.sforce.soap.enterprise.sobject.SObject[] {attach})[0];
if (sr.isSuccess()) {
System.out.println("Successfully added attachment.");
} else {
System.out.println("Error adding attachment: " + sr.getErrors(0).getMessage());
}
} catch (FileNotFoundException fnf) {
System.out.println("File Not Found: " +fnf.getMessage());
} catch (IOException io) {
System.out.println("IO: " +io.getMessage());
}
But to make it simple, does there is any mule connector which automatically done all this and attach a file to the particular created case.

Yes you can use the Salesforce Cloud Connector for that. Example:
<file:file-to-byte-array-transformer />
<sfdc:create type="Attachment">
<sfdc:objects>
<sfdc:object>
<body>#[payload]</body>
<name>test.docx</name>
<parentid>#[message.inboundProperties['mysfdcparentid']]</parentid>
</sfdc:object>
</sfdc:objects>
</sfdc:create>
In the example, I am setting the sobject type to 'Attachment'.
The body element is the file itself. Note that the connector will handle the base64 encoding for you, you just need to provide it with a byte array. If you're using File, you can use file:file-to-byte-array-transformer for example.
The parentid is set using MEL to get the value from a message property. So if you have a previous SFDC operation you can use MEL to extract the value of the previous sobject.

Related

Image received by Kafka-console-consumer is processed correctly but by java program it is corrupt. How to solve this?

I am trying to send an image from one kafka-producer to another kafka-consumer. I have written a java program for the consumer and when the data (image converted to bytes) is received by kafka-console-consumer as (terminal command > imageName.jpg ) it is showing correctly in the image viewer but when I am trying to consume this image data by a java-consumer, the image viewer isn't able to open the image (as it is corrupt).
Java Producer:
The Producer first converts the image to byte
public static byte[] getByte(File f) throws IOException {
byte[] buffer = new byte[1024];
ByteArrayOutputStream os = new ByteArrayOutputStream();
FileInputStream fis = new FileInputStream(f);
int read;
while((read = fis.read(buffer)) != -1){
os.write(buffer, 0, read);
}
fis.close();
os.close();
return os.toByteArray();
}
Then the producer configurations are as follow
properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, args[1]);
properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName());
When I receive the data sent by this java producer, using CLI, the image is correctly shown. The command is
kafka-console-consumer.sh --bootstrap-server server1 --topic topic-name > imageName.jpg
The thing is that I am not giving any other consumer configuration (such as for deserializing, etc.) other than those mentioned in the command above.
Java Consumer:
I thought that I would simply save the producer's data value into a jpg file and it would work. I thought that because I didn't give any other configs in the CLI command as well. The Java Consumer is as follows
//String bootstrapServer = args[0];
String bootstrapServer = "[::1]:9092";
String group_ID = "myThirdApplication";
//String topic = args[1];
String topic = "second_topic";
// Create Consumer Properties
Properties properties = new Properties();
properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer);
properties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
//properties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
properties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
properties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, group_ID);
properties.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, /*"none/earliest/latest"*/ "earliest");
properties.setProperty(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG, CooperativeStickyAssignor.class.getName());
I have tried both StringDeserializer which saves the data into a file but the file (which is supposed to be an image file) is corrupt and ByteArrayDeserializer seem to give an error.
This is how I am saving the file
String fileName = String.valueOf(record.timestamp()) + ".jpg";
File myFile = new File(fileName);
try {
if(myFile.createNewFile()){
log.info("File Created: " + myFile.getName());
}
} catch (IOException e) {
log.info("An Error Occurred While Creating File!");
e.printStackTrace();
}
FileWriter data = null;
try {
data = new FileWriter(fileName);
log.info("FileWriter Created!");
} catch (IOException e) {
log.info("An Error Occurred While Creating FileWriter!");
e.printStackTrace();
}
try {
data.write(Byte.valueOf(record.value()));
log.info("Successfully Written Data!");
} catch (IOException e) {
log.info("An Error Occurred While Writing File!");
e.printStackTrace();
}
try {
data.close();
log.info("File Closed!");
} catch (IOException e) {
log.info("An Error Occurred While Closing File!");
e.printStackTrace();
}
I thought the problem lies in the deserialization. I tried to know the default deserialization that kafka-consumer use, but I found that there is no default setting for this.
EDIT 1:
I am sharing a snippet of the file which is actually being received on the console vs in the java program:
Console --
lmd#-z syB(^7"��ix0p탮`Q*s7.K#���q(]P;'$+p k+kL׌N|QBjSA]KR1je?Q]#mU(Vj7s ��<y02w- >s)lFsHͳyEE,5u\VK 6,a?2uþ"]Х',QALi緉#|yi.*(HQʳu2duWH,#͹f|eM5zx8xa%ŧXN}%UD ;rs$rF(pGA2xR9TJ.s3afcpT/1G;Ġ|`5Hux\��&`oτ^q܁R]2/[GP߳F5p){fiae?Ԩ!WKFJ,)Cr`;?gOW;= ȣ8dA)2]NLz(RwÁJqWKV~^!7̰WQ��0aըԻFT!C(ULR5ss_MxTQ\UCk&wFeyIQ<ij\#s ތO,m_iJV1YB.."Qc2"<5(hgGd0О <oPLSCYcu3.;pڜ
ӼKLߺ>vbCdŚ<ꃶ邮k{BYML!3!*OTY(;3֦u(8ϦU&hlbk"xp5I}WdS>c1 vy{* -c0k:rm^扖{mF-ц}nsj[߹J*>eg2&
#s ;$xd[3h: [۪!FQ^gkmO1#SrQAx]wkEi&m}ـn!0$TV!'4x<~Uܰw?xcd<<\��_wu/r3˓k0v+<CPvf,\wش/?I^p䁰YzI6ür;:288ʯ2R-WxqUۺ4Fʼ\sF13|м1]EU{Cd$V?XmOЙ恪H7h5A'w0DN_IoPs0%eVc63[TcOVUMX<r]9q7rhFW&Y`Gm&(v+2ߨc+
.ᅡX=Q;L y"^#jdvuw56)6_Еl^n
LTP"}eN55 ڟ5T+cA;GEqR#[fq/s2RΡdG Nf^e^,Bc)0]>eYs/q+cLNvL"=䇕<wlE^n.7qjj
;#딥ȓ͚2I*;Ps2¸o]ҥ兜xGԼCt]b(e~O\V4H9r\uxxjl5^._BGm rg/zcj%PLD:T2?~{Tv%eG2=* s6X2K.yG%v~æK㾸7;3Je#F])[0<omҡP)]`7
#uD(8-%re+
lK!Jkx0#UJ[>3j#`4dRs.voH3Txiy̵IC{0[.ٔDFTflbeKe?#h~ӈg,7U!e5Q,̥C9$}GN6{o#ESoL%Y
<6V8+Ajpx9o|(602wPK4y*;3//
R˯Ńn{7ITybƯ!)��]4d"!#{C ]WUwO KM[Ƨ٠}l35*c6IXA{zg/(I.\E8/h)LNSlEa˞Q퉠hwP&[Pb,;xf&בs]M~)+XCofNiIӁBmj548Q9њ>blNWBݏQ
2R=teḳ*TeJ%JnE%bg/jؙ c]:*x.
(qm
%L
pFdFR㙞wי/b;o!yo0L` 6<hY߬olqzw
"tUMi Tm~ef[.֠KX2_Sr0c4ǽ#7N`rcot]*dk5+Pf/݈"Xܸn2XJ3GhL#eh0mWپrY9Ϭɵ]9 *'c\iL^DWcZjj0ż14��{͔U)XevJi}55BܸofX^݈8G^:*>|Ba?CbzMwW%}fkneO
j]R\D&)3VҶ1S=݂c^ĉ'!)ṯkd+kϙqg0-!S}(LAWZ/cm> tFTj2KC.rMbvYyOK;:C-t#Hʚ6~kWw눘qQ̢y`Qhk2jY cV^;0!IW
3~MQb 5d_!)L^=۩i!k48zhl^W+#\;vxCJL*)MB햃
ĥe^bbD:'H!r1ZTDo1QL M1#BAFmϷb
ᅲ9,91,ąs%ˡⰎBHB(/UKgVaP/1Cz!NaS|e;K2d*#"}>"1P:9E._V#Ōwo%#ʗcw':au=fQ'61/U&}=h؎i;HDkQk!*p½
vB%+*:S0c+BYRѮgn,nZpJFdܽX"zyP]1%Vn%|L!ЯɊjMmԲ\+rL'SqZd5B%+r7u-f|
&)DbSYe9,b"��a؎ؕI%ŗ2#vNǘ!ygZU,
o^!\SIf2yh*э0c+↢0 Iw?
!"D[e"]3[Ar(>/̴؁HYK9&"(W3Jm\aa1Бu>\Z5HЗ)*_:_Igfp渎7jJ撺s9 rn]UMp]0,<lsy6sx'0]vS/љ5ؗ1S6ԾfbdIQʸGNERJHSH^ ]ہ̬j<y̌dA-Xaxkjĵ0��%Il,TJm4:M۲^ňݣqe͎VEe\xH1P&TYJ{-c0D]&pFXgf]#*,B27q4dάבHK^sӶnR/#PP|oS_.?x">!"Dۓ,-̦UMCtj-jR;COKOrf^C;;b.%+sDPs46 e~"6Uu,��ieX5Ţ=.l.W$XO⸆ݦLf_,v슈**YL|G}&mj`yB)is9L!eK[h"ZeY"{8Db&lM~)Z1W9EWPEVt$x\MZec/&rL߳+Lu~e6pQ5jܽlDlf gO>!7sL&0Gl%8b0IR;FR.zqCYc.ΝF3ɘ0c(o\]ao1R0B
#��&dtib",B6Ypk*DzoEb+SB.#f%J0
A9'(p6.?6cSU&ӮY:'MTL
H_EF΀(Eb19*T,#B%&F쭠V^Θ3&dFXvB!.%pAFM1\Lᇼ f0$_M\As vwxq0!HbY!
IntelliJ --
???tC???v?xE?x?w)f??[O??J??I????\?`?*)??$R??tq,?* 5?H#x?_?Ka8/??l?^?? jo??0??V?x0?l??#a]?y&Sq?xc???t?S?P?M???/u??8G)
???v?o??0s0(_L??t?#??M???J???H A#Xe???iy?S??_ ?<?1?Kp?????[?}?�_ _?W????3????????{??56?k???c???j?JZ???????3?'?_v? ???6p~???}????o??Z?Op<?t???9???:??�? i?rd/???[?? ??]pAPQsx?????q>]N!S#????2?(?jiW?}???;?c?C?xM^?V?YP?#F?k3?g?r?.mK??Ej3
[H???h
L??.]? t?sb~?1?m?#?q?5?vE?u??????\?.??g,Bd.U??#?,*]#!(??Q??????B?y??????Li????E??????p??X??k?????????+?? N?p???By?????p?7?zY? ??????EN?I??.???�8`F??aK? u?_?? ?x??? oRs??_(?{R?XE,?2U
)???*?^?qz{???1?x?6/???I<??JZ!???<??]?E6????f ???]p?)??&??,? ??)?w?"? ? m?h?*???2?+?Xx;??v??
h?Fb#?!?P^????%?Zo?p|u?b\?e^%-&eQ6?u???N?? ?<??x??#J????XZ?Gz?i? ???(?_D??~Z??O?\,?y$NU??R-?sx??+???u,&L???????&????%?Y? k???
?#?+??W?!??Q??????Z5?Eiec?H5??_#???4?7P??P?S??\?6-�8??.?"u? )v?mz,?? ??A?I???j?e?28-(XR*??(??~?U0i%?xz??t?v? 5??wj2,U??�3M??Y?#,=z?N_?h_EB7???E???????z?????X??????????????01?I?x??r?m?#?&<W??????a4?ly???!N?X???}?J?Z`??? ?????WG???r?Z??&Q?:?m??3*?"?2_?3BU???<?iL??#???#I
?q?0?L??%Z??yHj??E.??TH?>W?? f?? ???????_?Q?Y?Otn'?#?&?)??:`?-?SL???????U?-?????,Q?0{?f4q???Nm|F??#??=?y?8_??gj\u5n?/>??h??\??$}?
Oe?$sQT}\ ??P{??s????N??;?#P?m???B?PTZ? ????m???a?S??U*??./3??F?0???????gD??8^?UjSVv-S??)?"???k??IJF?b???q6R`1????{??`Z?W????????TR????:??????????CZ6??????[!qI?????e?A????\????C-???WdAnRN???v%p??j?+???F?*????p??[lZ=?#??K??
#at3?bK?5"6#? ???)+?
?Lg ??.k
???(?+-?O??Bo???V C?l!??xc?4??7<??*>V?S??
Zlv??oUJHl?p?1
??? io??k?QEyahR?O? ]??,&??+?V#??0?h????(0I?:~?h(Jy?X?M????6(?R#OiIv?a??#?l?k?%?E????Pai??O#j?X?y???.W??z?Y^s??-??b?$|?#?x?EO[wp???XK??????H?.Y???8?(??(Y?I?W4?0)?t/?1%?2??$?? ??????yQ??Ig?q#???^?s??a?/'?T?>a_}???jW5-qlZ?
?jK?Qls?}xE2??g?????o2???ji^?Yy?O??uLTZ:?P
? i?5h??[0? ????{ ????N????
??H`??L??xZz!?P?^?7?$??.#,?Sg?O?(?Af?sgp?j??U?r???p???]/V?? J'?Q?? Y8??|Q?EZ??;?"=???
1?????BGe~?P*lr??D[
???5&]???|?Y?)??S}?rQ??O ?n??????D?a#???d7"Il'.?+k?J?j+??#j????L? ]%G??f8??4]P???W???8?<T#
I don't know how to define this but there is clearly a difference between what is being received on console vs on IntelliJ.
EDIT 2:
I found the solution but this wasn't the exact problem. I found out that I was using the wrong KafkaConsumer. I was using
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(properties);
Whereas, I should have used
KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>(properties);
I am thankful for everyone who has tried to solve this issue and I am sorry for my silly mistake.
This is not a bug in ByteArrayDeserializer.
You are doing a wrong conversion. Remember that ConsumerRecord is generic, and it is your responsibility use received key/value as correct types, that match the Deserializers provided.
In your code you are doing:
data.write(Byte.valueOf(record.value()));
what invokes Byte.valueOf(String).
Extract the received record-value, you do not need convert it. To show it explicitly:
byte[] bytes = record.value() // you just get the bytes
data.write(bytes)

Domino app - how to access the source document in java during custom file attachment routine

This is a non-xpages application.
I have inherited some code that I need to tweak....this code is used in a drag&drop file attachment subform. Normally, this will create a document in a separate dedicated .nsf that stores only attachments, and uses the main document's universalid as a reference to link the two....I need to change what the reference is to the value in a field already on the main document (where the subform is).
Java is challenging to me, but all I need to do is GET the value of the field from the main document (which has not necessarily been saved yet) and write that string value onto the attachment doc in that storage database, so I think I am just needing help with one line of code.
I will paste the relevant function here and hopefully someone can tell me how I get that value, or what else they need to see what is going on here.
You can see my commented-out attempt to write the field 'parentRef' in this code
...
private void storeUploadedFile( UploadedFile uploadedFile, Database dbTarget) {
File correctedFile = null;
RichTextItem rtFiles = null;
Document doc = null;
String ITEM_NAME_FILES = "file";
try {
if (uploadedFile==null) {
return;
}
doc = dbTarget.createDocument();
doc.replaceItemValue("form", "frmFileUpload");
doc.replaceItemValue("uploadedBy", dbTarget.getParent().getEffectiveUserName() );
Utils.setDate(doc, "uploadedAt", new Date() );
doc.replaceItemValue("parentUnid", parentUnid);
//doc.replaceItemValue("parentRef", ((Document) dbTarget.getParent()).getItemValue("attachmentDocKey"));
//get uploaded file and attach it to the document
fileName = uploadedFile.getClientFileName();
File tempFile = uploadedFile.getServerFile(); //the uploaded file with a cryptic name
fileSize = tempFile.length();
targetUnid = doc.getUniversalID();
correctedFile = new java.io.File( tempFile.getParentFile().getAbsolutePath() + java.io.File.separator + fileName );
//rename the file on the OS so we can embed it with the correct (original) name
boolean success = tempFile.renameTo(correctedFile);
if (success) {
//embed original file in target document
rtFiles = doc.createRichTextItem(ITEM_NAME_FILES);
rtFiles.embedObject(lotus.domino.EmbeddedObject.EMBED_ATTACHMENT, "", correctedFile.getAbsolutePath(), null);
success = doc.save();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
com.gadjj.Utils.recycle(rtFiles, doc);
try {
if (correctedFile != null) {
//rename the temporary file back to its original name so it's automatically
//removed from the os' file system.
correctedFile.renameTo(uploadedFile.getServerFile());
}
} catch(Exception ee) { ee.printStackTrace(); }
}
}
}
...
dbTarget.getParent does not do what you think it does. It returns a Session object that is the parent session containing all your objects. Casting it to (Document) won't give you your main document.
I don't see the declaration for it, but you appear to have a variable available called parentUNID. You can use it to get a handle on the main document.
You need to use the parentUNID value in a call to getDocumentByUNID() in order to retrieve the Document object representing your main document. But in order to do that, you need the Database object for the nsf file containing the main document, and if I understand you correctly, that is a different database than targetDb.
I'm going to have to assume that you already have that Database object in a variable called parentDb, or that you know the path to the NSF and can open it. In either case, your code would look like this (without error handling):
Document parentDoc = parentDb.getDocumentByUNID(parentUNID);
doc.replaceItemvalue("parentRef", parentDoc.getItemValue("attachmentDocKey"));

Send Template as Envelop Docusign Java

I have create Template on my docusign account. I want to use this template to send to recipients in my application using Docusign-Java-Client Program.
Right now I am reading .pdf from my local machine but i don't want to use local document, i want to use Template on docusign.
How can i read that Template in java?
i will do same in scala.
Code in Scala :
val loginInfo = authApi.login()
val loginAccounts: java.util.List[LoginAccount] = loginInfo.getLoginAccounts
val SignTest1File = "/TermsnConditions.pdf"
var fileBytes: Array[Byte] = null
try {
val currentDir = System.getProperty("user.dir")
val path = Paths.get(currentDir + SignTest1File)
fileBytes = Files.readAllBytes(path)
} catch {
case ioExcp: IOException =>
System.out.println("Exception: " + ioExcp)
}
Please check https://github.com/docusign/docusign-java-client/blob/master/src/test/java/SdkUnitTests.java SDK, and it has a sample method RequestSignatureFromTemplate() to request signature using templates.

Sending in-memory generated .docx files from server to client with Spark

I am creating a web application using the Spark Java framework. The front-end is developed using AngularJS.
I want to generate a .docx file on the server (in-memory) and send this to the client for download.
To achieve this I created an angular service with the following function being called after the user clicks on a download button:
functions.generateWord = function () {
$http.post('/api/v1/surveys/genword', data.currentSurvey).success(function (response) {
var element = angular.element('<a/>');
element.attr({
href: 'data:attachment;charset=utf-8;application/vnd.openxmlformats-officedocument.wordprocessingml.document' + response,
target: '_blank',
download: 'test.docx'
})[0].click();
});
};
On the server, this api call gets forwarded to the following method:
public Response exportToWord(Response response) {
try {
File file = new File("src/main/resources/template.docx");
FileInputStream inputStream = new FileInputStream(file);
byte byteStream[] = new byte[(int)file.length()];
inputStream.read(byteStream);
response.raw().setContentType("data:attachment;chatset=utf-8;application/vnd.openxmlformats-officedocument.wordprocessingml.document");
response.raw().setContentLength((int) file.length());
response.raw().getOutputStream().write(byteStream);
response.raw().getOutputStream().flush();
response.raw().getOutputStream().close();
return response;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
I have tried to solve this in MANY different ways and I always end up with a corrupted 'test.docx' that looks like this:
Solved it by using blobs and specifying the response type as 'arraybuffer' in the $http.post api call. The only bad thing with this solution (as far as I know) is that it doesn't play well with IE, but that's a problem for another day.
functions.generateWord = function () {
$http.post('/api/v1/surveys/genword', data.currentSurvey, {responseType: 'arraybuffer'})
.success(function (response) {
var blob = new Blob([response], {type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'});
var url = (window.URL || window.webkitURL).createObjectURL(blob);
var element = angular.element('<a/>');
element.attr({
href: url,
target: '_blank',
download: 'survey.docx'
})[0].click();
});
};
I think what went wrong was that the byte stream got encoded as plain text when I tried to create a URL with:
href: 'data:attachment;charset=utf-8;application/vnd.openxmlformats-officedocument.wordprocessingml.document' + response
thus corrupting it.
When using blobs instead, I get a "direct" link to the generated byte stream and no encoding is done on it since the response type is set to 'arraybuffer'.
Note that this is just my own reasoning of why things went wrong with the original code. I might be terribly wrong, so feel free to correct me if that's the case.

Read email contents using Apache Commons Email

I've different properties file as shown below:
abc_en.properties
abc_ch.properties
abc_de.properties
All of these contain HTML tags & some static contents along with some image urls.
I want to send email message using apache commons email & I'm able to compose the name of the template through Java using locale as well.
String name = abc_ch.properties;
Now, how do I read it to send it as a Html Msg parameter using Java?
HtmlEmail e = new HtmlEmail();
e.setHostName("my.mail.com");
...
e.setHtmlMsg(msg);
How do I get the msg param to get the contents from the file? Any efficient & nice solun?
Can any one provide sample java code?
Note: The properties file has dynamic entries for username & some other fields like Dear ,....How do I substitute those dynamically?
Thanks
I would assume that *.properties is a text file.
If so, then do a File read into a String
eg:
String name = getContents(new java.io.File("/path/file.properties");
public static String getContents(File aFile) {
StringBuffer contents = new StringBuffer();
BufferedReader input = null;
try {
InputStreamReader fr=new InputStreamReader(new FileInputStream(aFile), "UTF8");
input = new BufferedReader( fr );
String line = null;
while (( line = input.readLine()) != null){
contents.append(line);
contents.append(System.getProperty("line.separator"));
}
}
catch (FileNotFoundException ex) {
//ex.printStackTrace();
}
catch (IOException ex){
//ex.printStackTrace();
}
finally {
try {
if (input!= null) {
input.close();
}
}
catch (IOException ex) {
//ex.printStackTrace();
}
}
return contents.toString();
}
regards
Hi Mike,
Well, I kind of guess that you are trying to send mails in multiple languages by rendering the elements from different property files at runtime. Also, you said "locale". Are you using the concept of "Resource Bundles )"? Well, in that case before you send mails,
1)You need to understand the naming conventions for naming a property file, without which the java compiler will not be able to load the appropriate property file at run time.
For this read the first page on the Resource Bundles page.
2) Once your naming conventions is fine, you can load the appropriate prop file like this:
Locale yourLocale = new Locale("en", "US");
ResourceBundle rb = ResourceBundle.getBundle("resourceBundleFileName", yourLocale);
3) Resource Bundle property file is nothing but a (Key,Value) pairs. Hence you can retrieve the value of a key like this:
String dearString = rb.getString("Dear");
String emailBody= rb.getString("emailBody");
4) You can later use this values for setting the attributes in your commons-email api.
Hope you find this useful!

Categories