Skip to content

Instantly share code, notes, and snippets.

@mokamoto
Last active December 31, 2015 16:59
Show Gist options
  • Save mokamoto/8016925 to your computer and use it in GitHub Desktop.
Save mokamoto/8016925 to your computer and use it in GitHub Desktop.
<apex:page showHeader="false" standardController="Contact" extensions="SendMailFromTemplateController" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false" docType="html-5.0">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'/>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script type="text/javascript">
function s1close(){
Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{refresh:"true"}});
}
function templateselect(){
var templateId = $("#template").val();
Sendgrid1Controller.getContents(templateId,function(result, event){
if(event.status) {
$("#content").html(result).text();
}
});
}
function templateselect2(){
var templateId = $("#template").val();
Sendgrid1Controller.getSubject(templateId,function(result, event){
if(event.status) {
$("#subject").val(result);
}
});
}
function send(){
var subject = $("#subject").val();
var body = $("#content").val();
var address = '{!Contact.email}';
Sendgrid1Controller.sendEmail(subject,body,address,function(result,event){
$("#myModal").modal("show");
});
}
</script>
</head>
<body>
<div style="margin:20px;" />
<h5>1.Eメールテンプレートを選択</h5>
<div style="margin:20px;" />
<select id="template" class="form-control" onchange="templateselect2();templateselect();">
<apex:repeat var="template" value="{!templateList}">
<option value="{!template.id}">{!template.name}</option>
</apex:repeat>
</select>
<div style="margin:20px;" />
<h5>2.メールを編集</h5>
<div class="form-group">
<label for="subject">件名</label>
<input type="text" class="form-control" id="subject" />
</div>
<div class="form-group">
<label for="content">本文</label>
<textarea id="content" class="form-control" rows="3"></textarea>
</div>
<div style="margin:20px;" />
<h5>3.メールを送信</h5>
<button type="button" class="btn btn-primary btn-lg btn-block" onclick="send();">送信</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">送信完了</h4>
</div>
<div class="modal-body">
送信が完了しました。
</div>
<div class="modal-footer">
<button type="button" onclick="s1close();" class="btn btn-default" data-dismiss="modal">閉じる</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment