EMail enconding Hybris - email

I'm trying to send an email using the sendEmail action.
Everything goes well excepts for the email encoding. I need it to be UTF-8 but I can't find how set it up.

The default encoding should be UTF-8. Have a look at
de.hybris.platform.acceleratorservices.email.impl.DefaultEmailService
in the method
public boolean send(final EmailMessageModel message)
and:
protected String getBody(final EmailMessageModel message)
The only reason I would see, is that UTF-8 is not supported by your system. But that doesn't sound very likely.
Maybe you imported the template in the wrong encoding? The template for email subject and body is an attribute of the EmailPageTemplate. Look it up in hmc/backoffice in WCMS/Page templates. Restrict the search to Email Page Templates. Find your Template. The tab Administration holds the related templates. The attributes are called Html Email Template and Email Subject. Right click them and select edit (in new window) to view the content.
You can look up your templates for cms components in your email page in hmc/backoffice in system/output documents/communication templates.
The default code for a component is:
<siteUid>-<Component Typecode>-template
e.g.
mysite-CMSParagraphComponent-template
If the content is not correct, change it in hmc/backoffice or reimport it. An impex file would look like this:
$emailResource=jar:de.hybris.mystore.core.setup.CoreSystemSetup&/mystorecore/import/emails
$lang=en
UPDATE RendererTemplate;code[unique=true];description[lang=$lang];templateScript[lang=$lang,translator=de.hybris.platform.commerceservices.impex.impl.FileLoaderValueTranslator]
# Import MyCmsComponent for mystore
;mystore-MyCmsComponent-template;"MyCmsComponent Template";$emailResource/email-myCmsComponentTemplate.vm
# Import MyEmail Content
;mystore_My_Email_Body;"My Email Body";$emailResource/email-myEmailBody.vm
;mystore_My_Email_Subject;"My Email Subject";$emailResource/email-myEmailSubject.vm
Now make sure, that the files email-myCmsComponentTemplate.vm, email-myEmailBody.vm and email-myEmailSubject.vm in the directory mystorecore/import/emails are UTF-8 encoded.

Related

Salesforce send Email by Apex

I'm making by a requirement a code able to send an E-mail to an specific list of E-mails, due the fact that I must to include the attachments of the record I decided to use an apex class instead an e-mail alert. This object (A custom object ) must populate some fields in an email template with some of the record´s fields. I implemented the following code
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(lista);
mail.setTemplateId('00X21000000QR22');
//mail.setWhatId(idMinuta);
mail.setTargetObjectId('005d0000005NMIx');
mail.setSaveAsActivity(false);
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (ContentVersion document: documents)
{
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(document.Title);
efa.setBody(document.VersionData);
fileAttachments.add(efa);
}
mail.setFileAttachments(fileAttachments);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
I understood that to make the fields merge it´s necesary to use the WhatId method. In the related code, I have commented it because It generates an error (INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.)
My question is, if is it possible to do this with a custom object. I´m a little confuse with salesforce documentation beacuse it looks like the method supports a custom object, or maybe If I am forggeting something to include in the code.
If i keep the WhatID line commented, effectively the email is sent with the attachments and the Template but it is not populated.
I really need this kind of solution because the org have in this object at least 20 email templates, for me will be easier just to pass the Id of the template instead of makig a code with 20 different html codes for each situation
Thanks a lot
Please publish this question at Salesforce StackExcahnge https://salesforce.stackexchange.com/

How to display and store decrypted mailItem in Outlook

I am developing an Outlook-AddIn that automatically decrypts emails. So basically, the AddIn changes some MailItem properties (subject, body, attachments) when new mail arrives. The problem is that when I save the item then the decrypted message is synchronized with the server, which is really bad for end-to-end-encryption... If I don't save the item, then the explorer pane still shows the encrypted message and searching for emails (decrypted subject or body) does not work.
My question is: How can I display and (locally) store the decrypted mailItem, so that all the usual features like email searching still work?
Is there a way to stop synchronization for specific emails in .ost?
One solution that I came up with is to store a copy of the MailItem in a local .pst store. But in that case the user has to handle the messages in two different stores (.ost and .pst), which is not very user friendly. The requirement is that the user has to change his usual behaviour as little as possible when reading emails.
private void Outlook_NewMailEx(object Item)
{
Outlook.MailItem mailItem = Application.Session.GetItemFromID((string)Item);
if (mailItem != null)
{
// decrypt the mailItem
mailItem.Subject = "decrypted subject";
mailItem.Body = "decrypted body";
// save mailItem LOCALLY
// (don't synchronize the decrypted message with the server)
mailItem.Save();
}
}
I would be grateful for any help!
One solution that I came up with is to store a copy of the MailItem in a local .pst store.
That was my first thought of possible implementations.
Also you may consider the following scenarious:
Keep a decrypted copy of the item in a hidden folder. The GetStorage method of the Folder class returns a StorageItem object on the parent Folder to store data for an Outlook solution. A StorageItem object is stored at the folder level, allowing it to roam with the account and be available online or offline. The Outlook object model does not provide any collection object for StorageItem objects. However, you can use Folder.GetTable to obtain a Table with all the hidden items in a Folder, when you specify the TableContents parameter as olHiddenItems.
Once you have obtained a StorageItem object, you can do the following to store solution data:
Add attachments to the item for storage.
Use explicit built-in properties of the item such as Body to store custom data.
Add custom properties to the item using UserProperties.Add method. Note that in this case, the optional AddToFolderFields and DisplayFormat arguments of the UserProperties.Add method will be ignored.
Use the PropertyAccessor object to get or set custom properties.
See Storing Data for Solutions for more information.
Add custom properties to Outlook items with a decrypted content. So, when the item is going to be shown you can replace the content of built-in properties on the fly.
And the other solution is to store the decrypted information in the database. Note, you develop a managed add-in, so you can use all features of the .net framework.

Symfony2 Embedded Form Collection Not Validating

I have an entity Company and Address that have their own types CompanyType and AddressType. The AddressType is embedded in CompanyType. I did everything exactly the same as in Embedded Forms cookbook entry. The form is embedded correctly and is showing exactly as it should but validation is not working. I use separate .yml files for validation like this...
$yamlMappingFiles = $container->getParameter('validator.mapping.loader.yaml_files_loader.mapping_files');
$yamlMappingFiles[] = __DIR__.'/../Resources/config/validation/address_validation.yml';
$yamlMappingFiles[] = __DIR__.'/../Resources/config/validation/company_validation.yml';
$container->setParameter('validator.mapping.loader.yaml_files_loader.mapping_files', $yamlMappingFiles);
... and it is not validating in any of the entities. I tried corrupting the yml files and the parser throws an error which means that it loads the files. I also tried viewing var_dump($form->getErrors()); but it returns an empty array. At the same time, if i leave all blank fields in forms, the form isn't validated. Code is not entering here...
if( $form->isValid() ) {
... does not enter here if all input elements are empty ...
}
If I'm not mistaken, if no validation is used on a form, the form is always valid, so this must mean that validation .yml files are processed.
I didn't post any code beacuse my form is exactly the same as in the cookbook example. Just imagine that Task is Company and Tag is Addres.
Any ideas?

grails mail: render profile pictures from database in email

in grails-mail plugin you need do define your inline image data in your service, assuming you are using grails mail from a service.
you do this like so in your service.groovy
inline 'header', 'image/jpg', new File('./web-app/images/mailAssets/alert_header_pre.png')
inside your service definition, lets say:
def mailService
def contactUser(userName, email) {
mailService.sendMail {
multipart true
to email
from "marc.heidemann#live.de"
subject "Hello from grails-mail"
text "Hallo from grails-mail multipart text modus"
html view:"/alert/test", model:[name:userName]
inline 'header', 'image/jpg', new File('./web-app/images/mailAssets/alert_header_pre.png')
inline 'footer', 'image/jpg', new File('./web-app/images/mailAssets/suchebottomre.gif')
}
}
for now, the app is rendering the footer and the header image, Ok.
alright, now the plan of the planners of this project is to render profile pictures from database (about 15.000 users) in their emails - can and if then how can this be achieved without declaring every user's profile picture inside the service.groovy? Furthermore those pictures are stored outside of my app at amazon s3. might this be a boundary of mail plugin or is it possible to get this working? What would you offer those planning and creative guys as an alternative if it is not possible to do so? any opinions are welcome.
Loop through your users.
Get the corresponding picture from S3 using the grails-aws-plugin.
Insert picture into email
Send mail using the mail-plugin
That way you don't have to declare it in the service. You can download the pictures from S3 to use them as inline pictures or you could use a url provided by S3.
To access the file for inline usage:
def file = aws.s3().on(bucket).get(name, path)
To get a public url:
def url = aws.s3().on(bucket).url(name, path)

Email body in Symfony 1.4 mailer?

I'm using the Symfony 1.4 mailer where I build the various bits needed for an email and then send it out using:
$this->getMailer()->composeAndSend($sender, $recipient, $subject, $body);
In the email body, I need to able to take advantage of variables generated in the action, so right now I might have this in my action:
$body = 'Your username is '.$username.' and this is the email body.';
Does anyone know of an elegant way of storing/organising various email bodies, instead of having to code them like this straight into my action? I will have many email templates and will also have them in multiple languages.
I've found an old Askeet tutorial discussing this but it seems somewhat out of date with the new symfony 1.4 integration of SwiftMailer, and SwiftMailer documentation itself isn't very clear on this.
Thank you.
I store the email bodies as a template file and render them via sfPartialView. E.g. inside an action:
$view = new sfPartialView($this->getContext(), $this->getModuleName(), $this->getActionName(), 'confirmation_mail');
$view->setTemplate('_confirmation_mail.php');
// values can be set e.g. by setAttibute
$view->setAttribute('name', $name);
$body = $view->render()
The body templates are located in the module's template folder, but I am sure you can somehow change this and e.g. put all email templates into one folder if you want to.
How about just using the native method availible inside sfAction.
$this->getPartial('partial_name'); which works like the partial helpers for you templates.