Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to set email addresses dynamically in cMail component in mediation route

Hi,

 

I noticed that we can set email properties such as Host,To, Subject, From.. 

Can we do it dynamically? I have these values in properties of exchange object.

Generally we can use exchange properties in many components of mediation but how to use them in cMail component?

 

Thanks in advance!

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi Richard,

 

It worked with some play around. Basically talend cMail component does not provide the flexibility to set the values for the parameters available in it's setting (other than context variables).

But as you suggested it should work with headers, I added cSetHeader component before cMail component and it worked like charm. 

It looks like, in cMail if there is any header with which has the name same as the argument then header takes precedence over argument (option) in the uri.

 

Thanks once again!

View solution in original post

8 Replies
Anonymous
Not applicable
Author

I believe you can do this using headers and the Apache Simple language (http://camel.apache.org/simple.html). Set your headers using either a cProcessor or cSetHeader and use the Simple Language to assign the values in the cmail.
Anonymous
Not applicable
Author

Hi,

 

What I noticed is cMail component in talend is not allowing to access headers or properties of exchange.

When I put the context variables it works fine but when I try to put headers/properties, it does not recognize it.

Even there seems no option to use language. 

Anonymous
Not applicable
Author

Hmmmmm, I'm sure it should work..... but it can take some playing around to get it right. You shouldn't need to have the Single option, you should just need to format the String correctly. Unfortunately I can't try it here as I don't have my computer.

Something like....

"${in.header.headername}"

.....should do it.

Another (harder) way is to use PropertyPlaceholders. This is described below...
https://community.talend.com/t5/Design-and-Development/how-to-specify-dynamically-parameters-in-cMai...

Contexts will work, but you will not be able to change them at runtime.
Anonymous
Not applicable
Author

Hi Richard,

 

It worked with some play around. Basically talend cMail component does not provide the flexibility to set the values for the parameters available in it's setting (other than context variables).

But as you suggested it should work with headers, I added cSetHeader component before cMail component and it worked like charm. 

It looks like, in cMail if there is any header with which has the name same as the argument then header takes precedence over argument (option) in the uri.

 

Thanks once again!

Anonymous
Not applicable
Author

Glad you got it working. Did you use the Simple Language syntax I gave you?
Anonymous
Not applicable
Author

Not actually, I used 'Property' language to set the values in headers as I had the values available in exchange properties.

nboisvert
Contributor II
Contributor II

Can you provide code put in cprocessor and syntax used in cmail ? I'm facing the exact same problem and can't achieve it.

Arnaud_G
Contributor
Contributor

Hi 

Can you provide us the names of the headers you set before cMail , per each parameter (from, to, cc ....) ? 

Thanks