Let say I have a Contact Us form in Orchard CMS that I have created that had the following fields
Name:
Email Address:
Message:
Newsletter:
Now upon submitting this form I have it set to email a specific email address and I'm using the Tokens for the four fields to build the email so that the email received might look like this.
Name: John Smith
Email Address: jsmith#example.com
Message: Hi! I love your site and I hope you get some more content that I can use in the future!
Newsletter: True
Now this is fine, but the last field Newsletter is a boolean and I'd like the text represented here to be Yes/No (or potentially other custom words). How do I substitute the default True/False token values in the email for custom ones?
You'll probably need to implement your own token provider for this. Here is an example from the Orchard.Fields module... FieldTokens.cs
Note that there is no direct reference to the Orchard.Tokens project here so they use the event bus convention where you can define your own interface with the same name and signature as another event handler. Orchard will see this convention and treat your implementation as a handler for those events. I only mention this because it confused me at first. You can directly reference the tokens module if you want to.
Related
I have developed a form using form builder in Kentico Xperience.
I am using localized strings for the titles and texts of my form components.
For example for a radio button component, I have
which consists of the following localized strings:
It works fine until the form is submitted and sent by email.
The email template is built as follow:
$$label:Participation$$: $$value:Participation$$
But I receive email like:
Participation in meeting: {$Form.Participation.Virtual$}
While I would like to receive the localized text in my email as follow:
Participation in meeting: Virtually
How can I do that? Is there a specific syntax in the email template?
The correct syntax in my email template to obtain what I am looking for is:
$$label:Participation$$: {%Participation%}
The behavior is by design. If you use a compoment with list of options and you add just a localization macro there, there is a risk that chaning the string will cause wrong values. The recommended and supported format is:
value;{$ResourceStringKey$}
I have just started to use Kentico, so far everything has been straight-forward however I cannot get certain Macro's to work in Marketing Emails (to insert personalized information in the email such as their country).
Here is a quick overview of my automation process
Person submits a form on the website
Form field information gets mapped to the contact
Automation process begins
Internal/Transactional email sent which contains the requesters information (Macro's work)
Marketing email sent to requester, containing relevant information (Only basic Macro's work (for example recipient.firstname))
The issue is that the Macro's that are used (and working) in the internal transactional email do not appear to work in the marketing emails section, for example: {% OnlineMarketingContext.CurrentContact.ContactCountry #%} would copy in the requesters Country in the transactional/internal email, but it remains blank in marketing emails (Note: I have tested this fully, not as a draft email as I've read that the information doesn't get passed in a draft email).
I have tried using different objects (ContactManagementContext, etc.), however nothing appears to bring in personalized information.
Is there something I need to do to get the Macro's working within the Marketing Emails section? I have read through the docs online and I can't find anything to make this work.
Any help would be greatly appreciated.
The newsletter email macros are based off the subscriber not the contact. If you want to use the contact info, you will have to find a way to relate the subscriber to the contact.
This video shows how to see what macros are available.
Zach is correct. Normally, you would lookup the Contact based on the email address of the Recipient, e.g. {%GlobalObjects.Contacts.Where("ContactEmail = '"+Recipient.Email+"'").TopN(1).FirstItem%}. However, there is a hidden object you can use in marketing emails: {%Advanced.ContactInfo%}
Edit: addressing the first comment below and for clarity, this isn't a code question. The question is simply:
What do I put into the URI querystring of the new Gmail UI to view a draft message created by the Gmail API?
Despite this not really being a code question, I'm asking on Stack Overflow as it's Google's preferred platform for Gmail API questions.
--
If I view a draft message in the new Gmail UI, the URI is something like this:
https://mail.google.com/mail/u/1/?zx=iij9apqgzdf4#drafts?compose=jrjtXSqXwlFGnSGCQgDCdnHGVFdlpFMgzsCNgpQstQLxdLCMkjKstBmWZkCmjhWTQnpsZCJF
I can't see any way to create such a link from the Id or ThreadId of a message created via the Gmail API.
Previously, one could do this:
https://mail.google.com/mail/u/1/?zx=ov61dxfbrcga#drafts?compose=1631caae9dbb074d
where the value of "compose" is the Id.
How can the same thing be accomplished in the new UI?
I've been encountering the same problem and have had some success in this problem, as well as some issues I still can't get past.
Good news: The new compose parameter format is some kind of "base40" encoding. I searched the Gmail source for a restricted alphabet string, and found and deobfuscated the bit of code doing this encoding/decoding: https://gist.github.com/danrouse/52212f0de2fbfe33cfc56583f20ccb74
This code includes an encode and decode function which should work for Gmail-format query parameters.
Bad news: The values that it is encoding to open draft emails do not appear to be available using the Gmail API. Specifically, they look like this:
thread-f:NEW_THREAD_ID+msg-a:DRAFT_ID -- while the draft ID is the same as it was before, the Thread ID does not appear to match any of the IDs that the Gmail API returns.
Interestingly, if you inspect the subject row in the Gmail UI, it has dataset attributes including all of both the old format and new format IDs - but it's still unclear how to get the new ones programatically.
Thanks to #frank-szilinski - he pointed out that the old format is now translated. I.e. this now works again:
https://mail.google.com/mail/ca/u/1/#drafts/1661237c4db71ace
It doesn't seem to work when the Gmail tab isn't already open, however.
Building on #kremonte gist, and #chris-wood comments, I made a rails gem that correctly creates the open-the-draft-inside-gmail URL.
It's here - https://github.com/GoodMeasuresLLC/gmail_compose_encoder
It's for the use case of "my code created a draft (prepopulated with some text, of course) and now I want to open the draft in compose mode so that my user can review it before hitting "send".
How to get the URL for a draft
If, for example you use a list request from which you get your draft objects:
{
"id": string,
"message": {
object (Message)
}
}
You can take this id and put it into a URL in this format:
mail.google.com/mail/#inbox?compose=[id]
Eg.
mail.google.com/mail/#inbox?compose=3doinm3d08932d
This will open up GMail with the relevant draft open.
I was struggling because I wanted it to work with multiple accounts. However the authuser parameter did not help.
Inserting the email address instead of the integer after the u/ component solved the problem.
https://mail.google.com/mail/u/{email_address}/#drafts?compose={message_id}
The message id is the one provided by the API.
I cave created a custom list in sharepoint (created and provisioned to the 12 hive)
how can i perform validation on certain fields of the list when a new list item is added?
i think i can do it through the "itemadding" event reciever, but is there a more elegant sharepoint way?
eg i just want to check an email field has a valid email format.
I think you have to options. As you have already mentioned using a event receiver would be one way. But I think a more elegant and above all a more SharePoint like way would be implementing your own custom field type and field control.
This will give you the option to validate the mail address before any event receiver is triggered and to react with an validation message to the user giving him the option to correct his input.
You could go with validation on the client using JQuery if you have the id or a css class on the rendered textbox for the email input.
I'm building a SharePoint (MOSS) publishing site for employee information on my company website. I have an employee content type and am using the Contact E-Mail Address site column to store an employee's email address.
Want I'd like is the ability to encode email addresses at runtime to prevent the real email address from being harvested by spammers. This would be decoded when a user clicks the email hyperlink e.g. the following HTML would be sent to the browser:
Email Jonny
I already have the javascript methods for encoding/decoding a text value from the meaningless string above, but am not too sure as to how to approach this with SharePoint in mind. I'm thinking a custom control and/or custom J-Query?
Any help would be much appreciated!
Jonny
In the case that you are unable to put the users into AD, a custom field control will give you the ability to include the custom rendering (jquery) you require as well as the ability to enter the data as "normal" text.
The custom field, once defined "just works" wherever you need to display the field.
Given you are thinking of using JQuery, the issue then becomes one of making sure the jquery library is correctly linked whenever you need to us a field of this type.
If you make those employees members of the site, SharePoint takes care of this issue.
You can send emails to them, but the email address will only be used at send time, when you add a button to email someone, it will not show the email address, its handled at the backend.
SPUtility.SendEmail(SPContext.Current.Web, false, false,
[SPUser.Email][1], "E-mail title",
"E-mail body");
(source: msdn.com)
Two more options/approaches you can try:
(1) implement a custom TextField control, inheriting from Microsoft.SharePoint.WebControls.TextField and override RenderFieldForDisplay
Then in code - encode the field for display.
Add this control to safecontrols and use this in place of the normal TextField in the pagelayout.
(2) use the existing TextField control, but inject a button [Encode] using jQuery next to the TextField in editmode.
Use the JavaScript encode method to encode what the user has typed into an encoded value, replacing the existing TextField value. Which they can then save to into SharePoint.
I'd rate the approaches based on your deployment scenario - Nat's one is the cleanest but probably more involved for deploying, and the jQuery-only one seems very hackish but easy on deployment. The override TextField approach would probably sit somewhere in the middle.