-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
2Questions
-
2Replies
Track readstatus & open status in Apex class
Hello Every One,
I need some help .
I create a custom page which is similar to Standard email page.
Now my requirement is that whenever the recipient open the mail.I will notify by an email or any thing that recepient open mail or recipient get mail.
How i can do it?please help!!!!
For refrenceces i pasted my Visual force page & Apex Class here.
public class ReplyLead{
private final Task ts{get;set;}
public EmailMessage email{get;set;}
public Task tsk{get;set;}
public string additionalTo{get;set;}
public string to{get;set;}
public string cc{get;set;}
public String bcc{get;set;}
public String attachment{get;set;}
public List<Attachment> attList{get;set;}
public String subject{get;set;}
public String body{get;set;}
public String currentAttId;
public String currentQuoteId;
public Boolean toAddpresent;
public Boolean sendSuccess{get;set;}
public Quote qt{ get; set; }
public User usr{ get; set; }
public Quote UserEmail;
public String[] jsonDescriptionData;
public String parentId {get;set;}
// public Attachment attach {get;set;}
public String filename{get;set;}
public Attachment attach{get;set;}
public String recNo{get;set;}
public String attachId{get;set;}
public String FName{get;set;}
Public String fSize{get;set;}
Public blob bodypart{get;set;}
Public Boolean inLine{get;set;}
public transient String fbody{get;set;}
//public List<AttachmentWrap > attList1{get;set;}
public ReplyLead(ApexPages.StandardController controller){
email=new EmailMessage();
qt= new Quote();
toAddpresent=false;
sendSuccess=false;
attach = new Attachment();
currentQuoteId=ApexPages.currentPage().getParameters().get('retURl');
UserEmail=[select Id,contact.Email from Quote where Id=:currentQuoteId limit 1];
if(UserEmail.contact.Email !=null || UserEmail.contact.Email!= '')
to = UserEmail.contact.Email;
currentAttId=ApexPages.currentPage().getParameters().get('attid');
attList=new List<Attachment>();
attList=[Select id,Name,Body From Attachment WHERE Id=:currentAttId LIMIT 1];
System.debug('*********************************'+currentAttId);
this.ts=(Task)controller.getRecord();
tsk= new Task();
}
/* public void replyRec(){
System.debug('**************replyRec**************');
qt= new Quote();
}*/
public void upload()
{
//This shows how to insert an Attachment
attach.ParentId = currentQuoteId;
insert attach;
//return new ApexPages.Standardcontroller(attach).view();
}
public void doAttachment(){
try{
Attachment at=new Attachment();
system.debug('filename:'+filename);
system.debug('fbody:'+fbody);
system.debug('fSize:'+fSize);
at.Name=filename;
at.parentId =currentQuoteId;
String substring = fbody.substring(0, (fbody.indexOf(',')+1));
system.debug(substring );
at.Body =EncodingUtil.base64Decode(fbody.replace(substring ,''));//Blob.valueOf(fbody);
// at.inLine=false;
// insert at;
attList.add(at);
}
catch(exception r){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Attachment Size Crossed limit');
ApexPages.addMessage(myMsg);
}
}
public List<string> getjsonDescriptionData(){
try{
jsonDescriptionData = new List<string>();
List<User> UserList = [select id,Email,Name from User];
List<Contact> conList=[Select id,Email From Contact];
if(UserList != null && UserList .size() != 0){
Set<String > EmailSet= new Set<String>();
for(User acc : UserList){
EmailSet.add(acc.Email);
}
for(Contact con : conList){
EmailSet.add(con.Email);
}
for(String nam : EmailSet){
jsonDescriptionData.add('"'+nam+'"');
}
}
}catch(Exception ex){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,ex.getMessage()));
return null;
}
jsonDescriptionData.sort();
return jsonDescriptionData;
}
public PageReference sendReply() {
System.debug('**************sendReply**************');
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
//attach.setFileName(attList[0].name + 'pdf');
// attach.setBody(attList[0].Body);
system.debug('attList:'+attList);
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a :attList){
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(a.Name);
// a.body = EncodingUtil.base64Decode((a.body.tostring()).replace('data:text/plain;base64',''));
system.debug(fbody);
efa.setBody( a.body);
fileAttachments.add(efa);
}
if(to != null && to != ''){
email.setToAddresses(to.split(',').size() > 0 ? to.split(',') : new String[]{to});
toAddpresent=true;
}
if(cc != null && cc != ''){
email.setCcAddresses(cc.split(',').size() > 0 ? cc.split(',') : new String[]{cc});
}
if(bcc != null && bcc != ''){
email.setBccAddresses(bcc.split(',').size() > 0 ? bcc.split(',') : new String[]{bcc});
}
email.setSubject( subject );
email.setHtmlBody( body );
email.setFileAttachments(fileAttachments);
// email.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
if(toAddpresent){
if(!Test.isRunningTest()){
Messaging.SendEmailResult [] r =Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'Email Send Successfully'));
sendSuccess=true;
return null;
}else{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'To Address is mandatory to send email,Please Enter To address'));
return null;
}
}
public PageReference redirectQuotePage(){
System.debug('**************redirectQuotePage**************');
PageReference pageRef=new PageReference('/'+currentQuoteId);
pageRef.setRedirect(true);
return pageRef;
}
}
/////////////////////////////////////
<apex:page standardcontroller="Task" extensions="ReplyLead" id="pg">
<apex:includeScript value="{!URLFOR($Resource.jquery1, 'js/jquery-1.6.2.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery1, 'js/jquery-ui-1.8.16.custom.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.jquery1, 'css/ui-lightness/jquery-ui-1.8.16.custom.css')}"/>
<!-- <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<link rel="stylesheet" href="/resources/demos/style.css" />-->
<apex:form >
<apex:actionFunction name="goController" action="{!doAttachment}" rerender="pgblkta" >
<apex:param name="fsize" value="" assignTo="{!fSize}"/>
<apex:param name="fname" value="" assignTo="{!filename}"/>
<apex:param name="fbody" value="" assignTo="{!fbody}"/>
</apex:actionfunction>
</apex:form>
<apex:form id="fm" >
<apex:pageMessages />
<script type="text/javascript">
var blobfile;
function getAsText(readFile){
var reader = new FileReader();
reader.readAsDataURL(readFile);
reader.onload = loaded;
}
function loaded(evt) {
var fileString = evt.target.result;
blobfile = fileString;
var input = document.getElementById("fileId");
var fileName= input.value;
var size = input.files[0].size;
console.log(blobfile);
goController(size,fileName,blobfile);
}
function remoteLocationPost(){
var fbody= document.getElementById("fileId").files[0];
// alert(fbody);
getAsText(fbody);
}
</script>
<apex:actionFunction name="redirectPage" action="{!redirectQuotePage}" />
<apex:pageMessages id="errorMsg"/>
<apex:sectionHeader title="Activity" subtitle="Send a Reply" help="www.google.com" />
<apex:pageBlock id="pbmain" >
<center>
<apex:commandButton id="send" value="Send" action="{!sendReply}" oncomplete="callMethod();" reRender="errorMsg"/>
<apex:commandButton id="Cancel" value="Cancel" oncomplete="callMethod();" />
</center>
<apex:pageBlockSection id="pbscontid" columns="1">
<apex:pageBlockSectionItem >
<apex:outputText title="To" value="To:" />
<apex:inputTextArea value="{!to}" style="width: 200px; height: 35px;" required="true" styleClass="selectValue" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText title="CC(New PopupWindow)" value="CC:" />
<apex:inputTextArea value="{!cc}" id="tags" style="width: 200px; height: 35px;" required="false" styleClass="selectValue" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText title="BCC(New PopupWindow)" value="BCC:"/>
<apex:inputTextArea value="{!bcc}" id="p26" style="width: 200px; height: 35px;" required="false" styleClass="selectValue"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Subject" id="sbid" for="subid"/>
<apex:inputText value="{!subject}" label="Email" id="subid" style="width: 430px; height: 20px;" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="bodyid" value="Body"/>
<apex:inputTextarea value="{!body}" id="bodyid" richText="true"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Attachment" id="AttachId">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="Click the Browse button to find the file.(The file cannot be larger than 135KB and total attachment should not exceed 10MB.)"/>
<input type="file" id="fileId" name="attFile" /><br/>
<input type="button" value="Save" onclick="remoteLocationPost();" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!attList}" var="at" id="pgblkta">
<apex:column value="{!at.Name}" headerValue="Name"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<script>
function callMethod(){
var isCheck="{!sendSuccess}";
if (isCheck ==1)
alert("Email was sent successfully!!");
redirectPage();
}
</script>
<script>
$(function() {
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
$(".selectValue")
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "ui-autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source: function( request, response ) {
// delegate back to autocomplete, but extract the last term
response( $.ui.autocomplete.filter(
{!jsonDescriptionData}, extractLast( request.term ) ) );
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
//terms.push( "" );
//this.value = terms.join( "" );
this.value = terms;
return false;
}
});
});
</script>
</apex:page>
- devForce007
- September 19, 2013
- Like
- 0
Rerender Issue
Hello Guys,
I have a requirement in which one tab having all account name by click on the accont name.next tab will automatically display all the Related contact name.My problem is in next tab is not rendering so contact name is not display.
My Vf page is
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
and My controller is :-
- devForce007
- March 29, 2013
- Like
- 0
Look Up filter not working on Visualforce Page
Hi,
I have created a visualforce page where i've used standard controller as one of the custom object from my organisation.
On custom object , I've look up which has certain criteria defined. But when i use this Lookup as inputfield on Visualforce page, the look up window doesnt showing any records on it. The same look up filter works in Salesforce Native UI.
Can any one let me know why this is happening. Appreciatethe help.
Thanks in advance.
Dipak
- Dipak Nikam
- March 19, 2013
- Like
- 0
Can Approve & Reject Buttons be displayed inside an email in Approval notification
Hi ,
I am trying to figure out if the "APPROVE" and "REJECT" buttons could be displayed inside the email notification that is being sent to approver during the approval process?
Appreciate if anyone code through somelight on this.
Thanks,
Sai
- sai.ch
- February 07, 2013
- Like
- 0