function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
prats23prats23 

S-Control Javascript Error - Send Email functionality

Hi,

 

We have a old S-control on a custom object that is used to Email the details of the record to the current user's Email id.

This S-control was created long back.

 

But recently, we have found that the button on clik gives error "faultcode:"Soapenv:Client" faultstring:The content of elements must consist of well-formed character data or markup".

 

Well I am not able to debug the code, as it was written by someone else.

 

What do you reckon could be a possible solution?? I am really bad with S-controls but I know Javascript

 

Please help!

 

 

P.S. Creating this functionality using VF is on my mind, but i will try to debug this first!

b-Forceb-Force

Could you please post source code of S-control

It will be more easiar to look into it

 

Thanks,

Bala

 

prats23prats23

This is the small piece i wrote to test..

----------------------------------------------------------------

{!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")};
{!REQUIRESCRIPT("/js/functions.js")};

 

function layoutResults(sendEmailResult) {
try{
if (sendEmailResult.length > 0) {
if (sendEmailResult[0].getBoolean("success")) {
alert("Email has been sent!");
}
else { alert(sendEmailResult[0].errors);
//alert("Error here");
}
}
else { alert("Didn't get return data");
}
}
catch(err) {
alert('some stupid error');
}
} //function end



var singleRequest = new sforce.SingleEmailMessage();
singleRequest.replyTo = "myemailid@gmail.com";
singleRequest.subject = "Hello Test";
singleRequest.plainTextBody = "nothing in body";
singleRequest.toAddresses = ["myemailid@gmail.com"];

try{
var sendMailRes = sforce.connection.sendEmail([singleRequest], layoutResults);
}
catch(err){
alert("Error here is:"+err);
}

-------------------------------------------------------------

 

and this is the resulting alert i am receiving:

-------------------------------------------------------------

{fields:null, message:'Invalid to address : function (b) {
    var a = this.indexOf(b);
    if (a != -1) {
        this.splice(a, 1);
    }
    return this;
}', statusCode:'INVALID_EMAIL_ADDRESS', targetObjectId:null, }

-------------------------------------------------------------

 

Why do you think I am getting this error?? Moreover, email id given is proper!! Pls help!

b-Forceb-Force

ooops,

I had copy paste same code in my Org, It works fine ..... It show me result as Email has been sent

 

Thanks,

Bala

prats23prats23

and did you "recieve" the mail??

 

Well, In my org now i am getting different errors..

says "the content of elements must consist of well formed character data or markup."

 

Although.. i am using onlt 2 simple texts lines as subject and body..

 

Pls help!

b-Forceb-Force

I didnt receive any email ....... as I havent put any valid email id over there

 

but there was no any soap error

 

Thanks,

Bala

 

prats23prats23

Hey, I was trying a new idea.. pls see still not working......

 

I am trying to create a Email Functionality on click a custom button. i.e. I have a button that runs javascript on click and it executes the Apex class.

 

Button is:

-------------------

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}

var result=sforce.apex.execute( "EmailMe", "EmailFunction", {});
alert(result);

-------------------

 

Apex Class is:

--------------------

public with sharing class EmailMe {
    
    private String[] toAddresses;
    
    public EmailMe(){
        List<User> currentUser = [Select Email from User where Id =:UserInfo.getUserId()];
        String[] toAddresses = new String[] {currentUser[0].Email};
    }
    
    public String EmailFunction(){
        
             Messaging.reserveSingleEmailCapacity(4);
                     
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                
        mail.setToAddresses(toAddresses);
        mail.setSubject('Test Mail');
        mail.setPlainTextBody('Your Case has been created for testing');
        
        Messaging.SendEmailResult[] res = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        if(res[0].isSuccess()){
            return 'Email is sent';    
        }
        else{
            return res[0].getErrors()[0].getMessage();
        }            
    }
}

--------------------

 

But i am recieving something like this error:

 

"{http:// soap.sforce.com/schemas/package/EmailMe}Emailfunction please check the WSDL for the service.."

 

Do you think I have to setup some connection or something??

I am using my DEV org.

 

Help!!