私は現在、Java (Amazon EC2 インスタンス) でコーディングされたサーバーを持っています。このサーバーには、さまざまな Web サービスを実行するための多くのサーブレットがあります。これまでのところ、次のようなコードを使用して招待メールを送信しています。
public void sendInvitationEmail(String nameFrom, String emailTo, String withID)
{
SendEmailRequest request = new SendEmailRequest().withSource("invitation@myserver.com");
List<String> toAddresses = new ArrayList<String>();
toAddresses.add(emailTo);
Destination dest = new Destination().withToAddresses(toAddresses);
request.setDestination(dest);
Content subjContent = new Content().withData("My Service Invitation Email");
Message msg = new Message().withSubject(subjContent);
String textVer = nameFrom +" has invited you to try My Service.";
String htmlVer = "<p>"+nameFrom+" has invited you to try My Service.</p>";
// Include a body in both text and HTML formats
Content textContent = new Content().withData(textVer);
Content htmlContent = new Content().withData(htmlVer);
Body body = new Body().withHtml(htmlContent).withText(textContent);
msg.setBody(body);
request.setMessage(msg);
try {
ses.sendEmail(request);
}catch (AmazonServiceException ase) {
handleExceptions(ase);
} catch (AmazonClientException ace) {
handleExceptions(ace);
}
}
これで、コードによって生成された外部変数に基づいて、人の名前を含むメールを正常に送信できました。私の質問は、より複雑な HTML メールでこれを行うにはどうすればよいですか? より複雑なレイアウトの HTML ファイルを生成しましたが、コードでこれらの変数を変更する必要があります。このファイルは HTML であるため、大きなテキスト文字列として読み取って htmlVer 文字列に追加するだけでよいと思います (よくわかりません)。しかし、HTML ファイルを読み取り、いくつかの変数を変更して、これを Amazon SES のコンテンツ部分に追加するだけの簡単な方法があるかどうか疑問に思っていました。
ここで間違ったアプローチをとっていますか?