Question

Java Email Template Application: Create an application that creates a series of emails as outlined below....

Java Email Template Application:

Create an application that creates a series of emails as outlined below.

Create an array of email addresses that include the following data:

"   james   ,butler,[email protected]"

"Josephine,Darakjy,[email protected]"

"ART,VENERE,[email protected]"

Store a template for a mass email like this:

String template =

    "To:      {email}\n" +

    "From:    [email protected]\n" +

    "Subject: Deals!\n\n" +

    "Hi {first_name},\n\n" +

    "We've got some great deals for you. Check our website!";

When the application starts, it should read the email addresses and first names, merge them into the mass email template, and display the results on the console.

All email addresses should be converted to lowercase.

All first names should be converted to title case.

Test your application by adding names/emails to the list of email addresses without modifying any other code, the application should create more emails.

Test your application by modifying the template without modifying any other code, the application should change the content of the email that’s created.

Application output should look like this

Console

Emails

================================================================

To:      [email protected]

From:    [email protected]

Subject: Deals!

Hi James,

We've got some great deals for you. Check our website!

================================================================

To:      [email protected]

From:    [email protected]

Subject: Deals!

Hi Josephine,

We've got some great deals for you. Check our website!

================================================================

To:      [email protected]

From:    [email protected]

Subject: Deals!

Hi Art,

We've got some great deals for you. Check our website!

End

0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class Email {

public static void main(String[] args) {

String emailArray[]={" james ,butler,[email protected]","Josephine,Darakjy,[email protected]","ART,VENERE,[email protected]"};

String template =

"To: {email}\n" +

"From: [email protected]\n" +

"Subject: Deals!\n\n" +

"Hi {first_name},\n\n" +

"We've got some great deals for you. Check our website!";

System.out.println("Emails");

for(int i=0;i<emailArray.length;i++){

//my logic

//1.splitting the string which contain fristname , last name , email address

String temp[]=emailArray[i].split(",");

//taking the first name and trim the white spaces back and front of the string

String firstName=temp[0].trim();

//i want to change it to title case so taking first character and

//changing it to upper case then adding string from index 1

String modifiedFirstName=(firstName.charAt(0)+"").toUpperCase()+firstName.substring(1);

//taking email

String email=temp[2].trim();

//i am replace template string email with my email

String result=template.replace("{email}", email.toLowerCase());

//replaceing first name

result=result.replace("{first_name}", modifiedFirstName);

System.out.println("================================================================");

//printing results

System.out.println(result);

}

System.out.println("END");

}

}

Emails To: From: Subject: Deals! jbutlerChotmail.conm noreply@deals.com Hi James, Weve got some great deals for you. Check our website! josephine_darakjyEdarakjy.org To: From: noreply@deals.com Subject: Deals! Hi Josephine, Weve got some great deals for you. Check our website! To: From: Subject: Deals! art@venere.org noreply@deals.com Hi ART, Weve got some great deals for you. Check our website!

//////////////////////////////////////MAIN LOGIC/////////////////////////////////

Add a comment
Know the answer?
Add Answer to:
Java Email Template Application: Create an application that creates a series of emails as outlined below....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT