You need to sign in to do that
Don't have an account?
Bittus
How to create an inbound email service to create records from the data present in attached file,
Hi,
Actually i need to generate records in account object based on the data present in the attached file, which wll be sent to Salesforce through email. I am trying to do so using Inbound Email Service, but am only able to read the body of the email but not the attachment data.
Actually i need to generate records in account object based on the data present in the attached file, which wll be sent to Salesforce through email. I am trying to do so using Inbound Email Service, but am only able to read the body of the email but not the attachment data.
Hello Sushil,
Did u see the requirement which i posted regarding Email service, to create records from the data present in inbound mail attachment.
i have a code and it helps to get the inbound mail attachment and can read the data in the attachment. It is not givng any error, but am not able to create records from the data present n the attachment.
here is the code:-
global class ContactfromEmail implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
Contact contact = new Contact();
contact.FirstName = email.fromname.substring(0,email.fromname.indexOf(' '));
contact.LastName = email.fromname.substring(email.fromname.indexOf(' '));
contact.Email = envelope.fromAddress;
insert contact;
System.debug('====> Created contact '+contact.Id);
if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
Attachment attachment = new Attachment();
// attach to the newly created contact record
attachment.ParentId = contact.Id;
attachment.Name = email.binaryAttachments[i].filename;
attachment.Body = email.binaryAttachments[i].body;
insert attachment;
}
}
return result;
}
}
We are migrating to Lightning and will be using Files not Attatments on a custom object. Will the above code work, replacing attachment with file?
Thanks!
did u get the solution?