You need to sign in to do that
Don't have an account?

InboudEmailservices in inline image not appear on richtextarea(customfield)
HI all
I try to this code no errors, when i insert the caserecord . image will not appear on the richtextarea field
see this code
global class InboundEmailexample implements Messaging.InboundEmailHandler{
global messaging.InboundEmailResult handleinboundemail(Messaging.InboundEmail email,messaging.InboundEnvelope envp){
Messaging.InboundEmailResult result=new Messaging.InboundEmailResult();
Case c=new Case();
c.origin='Email';
c.Priority='Normal';
c.Status='Open';
c.subject=email.subject;
c.texxtimages__c=email.htmlBody;
insert c;
map<string,attachment> mapattachement=new map<string,attachment>();
if(email.binaryAttachments!=null){
for(Messaging.Inboundemail.BinaryAttachment ba : email.binaryAttachments) {
system.debug(ba);
for(integer i=0; i<ba.headers.size(); i++){
string headervalue=ba.headers[i].value;
system.debug('head'+headervalue);
system.debug('headername'+headervalue);
if(headerValue.startsWith('ii') || headerValue.startsWith('< image')) {
headerValue = headerValue.replaceAll('<', '').replaceAll('>', '');
mapattachement.put(headerValue, new Attachment(Name = bA.fileName, body = bA.body,
ParentId = c.Id, ContentType = bA.mimeTypeSubType));
}
}
}
}
insert mapattachement.values();
for(String headerValue :mapattachement.keySet()) {
system.debug(headerValue);
//Reference Link
String refLink = '/servlet/servlet.FileDownload?file=' +mapattachement.get(headerValue).Id;
c.texxtimages__c = c.texxtimages__c .replaceAll('cid:' +headerValue, refLink);
}
update c;
return result;
}
}
I try to this code no errors, when i insert the caserecord . image will not appear on the richtextarea field
see this code
global class InboundEmailexample implements Messaging.InboundEmailHandler{
global messaging.InboundEmailResult handleinboundemail(Messaging.InboundEmail email,messaging.InboundEnvelope envp){
Messaging.InboundEmailResult result=new Messaging.InboundEmailResult();
Case c=new Case();
c.origin='Email';
c.Priority='Normal';
c.Status='Open';
c.subject=email.subject;
c.texxtimages__c=email.htmlBody;
insert c;
map<string,attachment> mapattachement=new map<string,attachment>();
if(email.binaryAttachments!=null){
for(Messaging.Inboundemail.BinaryAttachment ba : email.binaryAttachments) {
system.debug(ba);
for(integer i=0; i<ba.headers.size(); i++){
string headervalue=ba.headers[i].value;
system.debug('head'+headervalue);
system.debug('headername'+headervalue);
if(headerValue.startsWith('ii') || headerValue.startsWith('< image')) {
headerValue = headerValue.replaceAll('<', '').replaceAll('>', '');
mapattachement.put(headerValue, new Attachment(Name = bA.fileName, body = bA.body,
ParentId = c.Id, ContentType = bA.mimeTypeSubType));
}
}
}
}
insert mapattachement.values();
for(String headerValue :mapattachement.keySet()) {
system.debug(headerValue);
//Reference Link
String refLink = '/servlet/servlet.FileDownload?file=' +mapattachement.get(headerValue).Id;
c.texxtimages__c = c.texxtimages__c .replaceAll('cid:' +headerValue, refLink);
}
update c;
return result;
}
}
I have not tried this, but after some research, I found this from below link see if that helps you.
http://simplyforce.blogspot.sg/2014/08/handling-inline-images-in-salesforce.html
Hope this helps you!
Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
Thanks and Regards
Sandhya