Send out mails to different individuals with separate info.

tahsin
tahsin New Altair Community Member
edited November 5 in Community Q&A
Number   City          Arrival         Airport  Name    Email
234    New York 2:39 PM         JFK   Alex    alex@email.com
221    Alabama  7:21 AM         ALB   John     john@email.com
122    Maine        7:07 PM          LGA  Chris   chris@email.com

I have a dataset like this, I want to use the email of the dataset to send out mails to each individual with their  information. I have used the Send Mail operator before but not quite sure how to email each individual with the info.  Each individual only get their own info in the email. 

Any help is appreciated. Thanks. 

Best Answer

  • Marco_Barradas
    Marco_Barradas
    Altair Employee
    Answer ✓
    Hi @tahsin,

    You can use this example to build what you need.

    You might need to install the Converters Extension to use the html macro to covert an example set to HTML table.

    Please contact me if you have further questions on how you can use the operator.

    It would be a great use of AI Hub since you can schedule a task to execute daily or ever x days to send data.
    <?xml version="1.0" encoding="UTF-8"?><process version="9.10.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.10.000" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="-1"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="generate_direct_mailing_data" compatibility="9.10.000" expanded="true" height="68" name="Generate Direct Mailing Data" width="90" x="179" y="34">
            <parameter key="number_examples" value="100"/>
            <parameter key="use_local_random_seed" value="false"/>
            <parameter key="local_random_seed" value="1992"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="9.10.000" expanded="true" height="82" name="Generate Attributes" width="90" x="313" y="34">
            <list key="function_descriptions">
              <parameter key="email" value="concat(name,&quot;@somedomain.com&quot;)"/>
            </list>
            <parameter key="keep_all" value="true"/>
          </operator>
          <operator activated="true" class="loop_examples" compatibility="9.10.000" expanded="true" height="82" name="Loop Examples" width="90" x="514" y="34">
            <parameter key="iteration_macro" value="example"/>
            <process expanded="true">
              <operator activated="true" class="extract_macro" compatibility="9.10.000" expanded="true" height="68" name="Extract Macro" width="90" x="45" y="34">
                <parameter key="macro" value="name"/>
                <parameter key="macro_type" value="data_value"/>
                <parameter key="statistics" value="average"/>
                <parameter key="attribute_name" value="name"/>
                <parameter key="example_index" value="%{example}"/>
                <list key="additional_macros">
                  <parameter key="age" value="age"/>
                  <parameter key="car" value="car"/>
                  <parameter key="zipcode" value="zip code"/>
                  <parameter key="email" value="email"/>
                </list>
              </operator>
              <operator activated="true" class="filter_example_range" compatibility="9.10.000" expanded="true" height="82" name="Filter Example Range" width="90" x="179" y="34">
                <parameter key="first_example" value="%{example}"/>
                <parameter key="last_example" value="%{example}"/>
                <parameter key="invert_filter" value="false"/>
              </operator>
              <operator activated="true" class="converters:example_set_2_html" compatibility="0.9.000" expanded="true" height="82" name="ExampleSet to HTML" width="90" x="313" y="34">
                <parameter key="macro" value="htmlMacro"/>
                <parameter key="Use a limit on Digits" value="false"/>
                <parameter key="Number of Digits" value="3"/>
                <parameter key="HTML class name for the table" value="rapidminer-table"/>
              </operator>
              <operator activated="true" class="send_mail_attachments" compatibility="9.10.000" expanded="true" height="82" name="Send Mail" width="90" x="648" y="34">
                <parameter key="to" value="%{email}"/>
                <parameter key="subject" value="Hello %{name} this if for you."/>
                <parameter key="use_html" value="true"/>
                <parameter key="body_html" value="&lt;html&gt;&#10;&#9;&lt;head&gt;&#10;&#9;&#9;&lt;title&gt;RapidMiner Mail Message&lt;/title&gt;&#10;&#9;&lt;/head&gt;&#10;&#9;&lt;body&gt;&#10;&#9;&#9;&lt;p&gt;&#10;&#9;&#9;Hello %{name};&#10;&#10;&#9;&#9;Now that your are %{age} old you are ready to buy your %{car}. Please find the best dealer close to %{zipcode} your zipcode.&#10;&#9;&#9;Also please use the following info.&#10;&#9;&#9;&lt;/p&gt;&#10;&#9;&#9;%{htmlMacro}&#10;&#9;&lt;/body&gt;&#10;&lt;/html&gt;&#10;"/>
                <list key="filenames"/>
                <list key="headers"/>
              </operator>
              <connect from_port="example set" to_op="Extract Macro" to_port="example set"/>
              <connect from_op="Extract Macro" from_port="example set" to_op="Filter Example Range" to_port="example set input"/>
              <connect from_op="Filter Example Range" from_port="example set output" to_op="ExampleSet to HTML" to_port="example set input"/>
              <portSpacing port="source_example set" spacing="0"/>
              <portSpacing port="sink_example set" spacing="0"/>
              <portSpacing port="sink_output 1" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Generate Direct Mailing Data" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" to_op="Loop Examples" to_port="example set"/>
          <connect from_op="Loop Examples" from_port="example set" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>


Answers

  • BalazsBarany
    BalazsBarany New Altair Community Member
    Hi @tahsin,

    this is a good use case for Loop Examples or Loop Values.

    Inside the loop you would filter the example set to the current example (Loop Examples: using the example number macro and Filter Example Range; Loop Values: Filter Examples for the current email address). 

    Then you use Extract Macro to create macros from the example values. You can use the macros in the email text.

    Regards,
    Balázs
  • tahsin
    tahsin New Altair Community Member
    Hi @BalazsBarany

    Thanks for your answer but I didn't quite understand it. I haven't worked with the loop that much so not much idea about it. 
  • BalazsBarany
    BalazsBarany New Altair Community Member
    Hi @tahsin,

    loops are an important and very useful feature in RapidMiner. You will need them sooner or later.
    I suggest that you put the operators I mentioned into an empty process, open their operator help and the sample processes. Most operators have simple sample processes that help you understand how they work. You can also search for videos in the Academy. 

    Regards,
    Balázs
  • Marco_Barradas
    Marco_Barradas
    Altair Employee
    Answer ✓
    Hi @tahsin,

    You can use this example to build what you need.

    You might need to install the Converters Extension to use the html macro to covert an example set to HTML table.

    Please contact me if you have further questions on how you can use the operator.

    It would be a great use of AI Hub since you can schedule a task to execute daily or ever x days to send data.
    <?xml version="1.0" encoding="UTF-8"?><process version="9.10.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.10.000" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="-1"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="generate_direct_mailing_data" compatibility="9.10.000" expanded="true" height="68" name="Generate Direct Mailing Data" width="90" x="179" y="34">
            <parameter key="number_examples" value="100"/>
            <parameter key="use_local_random_seed" value="false"/>
            <parameter key="local_random_seed" value="1992"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="9.10.000" expanded="true" height="82" name="Generate Attributes" width="90" x="313" y="34">
            <list key="function_descriptions">
              <parameter key="email" value="concat(name,&quot;@somedomain.com&quot;)"/>
            </list>
            <parameter key="keep_all" value="true"/>
          </operator>
          <operator activated="true" class="loop_examples" compatibility="9.10.000" expanded="true" height="82" name="Loop Examples" width="90" x="514" y="34">
            <parameter key="iteration_macro" value="example"/>
            <process expanded="true">
              <operator activated="true" class="extract_macro" compatibility="9.10.000" expanded="true" height="68" name="Extract Macro" width="90" x="45" y="34">
                <parameter key="macro" value="name"/>
                <parameter key="macro_type" value="data_value"/>
                <parameter key="statistics" value="average"/>
                <parameter key="attribute_name" value="name"/>
                <parameter key="example_index" value="%{example}"/>
                <list key="additional_macros">
                  <parameter key="age" value="age"/>
                  <parameter key="car" value="car"/>
                  <parameter key="zipcode" value="zip code"/>
                  <parameter key="email" value="email"/>
                </list>
              </operator>
              <operator activated="true" class="filter_example_range" compatibility="9.10.000" expanded="true" height="82" name="Filter Example Range" width="90" x="179" y="34">
                <parameter key="first_example" value="%{example}"/>
                <parameter key="last_example" value="%{example}"/>
                <parameter key="invert_filter" value="false"/>
              </operator>
              <operator activated="true" class="converters:example_set_2_html" compatibility="0.9.000" expanded="true" height="82" name="ExampleSet to HTML" width="90" x="313" y="34">
                <parameter key="macro" value="htmlMacro"/>
                <parameter key="Use a limit on Digits" value="false"/>
                <parameter key="Number of Digits" value="3"/>
                <parameter key="HTML class name for the table" value="rapidminer-table"/>
              </operator>
              <operator activated="true" class="send_mail_attachments" compatibility="9.10.000" expanded="true" height="82" name="Send Mail" width="90" x="648" y="34">
                <parameter key="to" value="%{email}"/>
                <parameter key="subject" value="Hello %{name} this if for you."/>
                <parameter key="use_html" value="true"/>
                <parameter key="body_html" value="&lt;html&gt;&#10;&#9;&lt;head&gt;&#10;&#9;&#9;&lt;title&gt;RapidMiner Mail Message&lt;/title&gt;&#10;&#9;&lt;/head&gt;&#10;&#9;&lt;body&gt;&#10;&#9;&#9;&lt;p&gt;&#10;&#9;&#9;Hello %{name};&#10;&#10;&#9;&#9;Now that your are %{age} old you are ready to buy your %{car}. Please find the best dealer close to %{zipcode} your zipcode.&#10;&#9;&#9;Also please use the following info.&#10;&#9;&#9;&lt;/p&gt;&#10;&#9;&#9;%{htmlMacro}&#10;&#9;&lt;/body&gt;&#10;&lt;/html&gt;&#10;"/>
                <list key="filenames"/>
                <list key="headers"/>
              </operator>
              <connect from_port="example set" to_op="Extract Macro" to_port="example set"/>
              <connect from_op="Extract Macro" from_port="example set" to_op="Filter Example Range" to_port="example set input"/>
              <connect from_op="Filter Example Range" from_port="example set output" to_op="ExampleSet to HTML" to_port="example set input"/>
              <portSpacing port="source_example set" spacing="0"/>
              <portSpacing port="sink_example set" spacing="0"/>
              <portSpacing port="sink_output 1" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Generate Direct Mailing Data" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" to_op="Loop Examples" to_port="example set"/>
          <connect from_op="Loop Examples" from_port="example set" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>


  • tahsin
    tahsin New Altair Community Member
    @MarcoBarradas thanks for your response. Exactly what I was looking for. Will let you know if I have any further question. Appreciate your help.