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
G P 18G P 18 

Non static method cannot be referenced from a static context: void EmailManager.sendMail(String, String, String)

Non static method cannot be referenced from a static context: void EmailManager.sendMail(String, String, String)
Raj VakatiRaj Vakati
Give me your code i will rewrite it ..  because you are refeing the static method from non static method 
G P 18G P 18
trigger ExampleTrigger on Contact (after insert, after delete) {
    if (Trigger.isInsert) {
        Integer recordCount = Trigger.New.size();
        // Call a utility method from another class
        EmailManager.sendMail('pgayam6@gmail.com', 'Trailhead Trigger Tutorial', 
                    recordCount + ' contact(s) were inserted.');
    }
    else if (Trigger.isDelete) {
        // Process after delete
    }
}
Raj VakatiRaj Vakati
Give me an email manager class 

and try this code also 
 
trigger ExampleTrigger on Contact (after insert, after delete) {
    if (Trigger.isInsert) {
        Integer recordCount = Trigger.New.size();
        // Call a utility method from another class
		EmailManager em = new EmailManager() ;
        em.sendMail('pgayam6@gmail.com', 'Trailhead Trigger Tutorial', 
                    recordCount + ' contact(s) were inserted.');
    }
    else if (Trigger.isDelete) {
        // Process after delete
    }
}

 
G P 18G P 18
Thanks Raj ....It's working now.
Raj VakatiRaj Vakati
close this thread!
rajubalajirajubalaji
Hi Raj,

Can you help me on this issue.

@isTest
public class testCode {
    @isTest
    public static void testCode(){
        List<String> Countries = new List<String>();
        List<String> Languages = new List<String>();
        Map<String, List<String>> countryMap = new Map<String, List<String>>{
            'Germany' => new List<String>{'German'},  
                'Spain' => new List<String>{'Spanish'},
                    'France' => new List<String>{'French'},
                        'UnitedStates' => new List<String>{'English', 'Spanish'},
                            'Canada' => new List<String>{'English', 'French'}};
                                for(String c : 'Spain'){
                                    for(String l : 'Spanish'){
                                        if(countrymap.containskey(c) && !Countrymap.get(c).contains(l)){
                                            adderror( 'country ' + c + ' does not support language ' + l);
                                            return;
                                        }
                                    }
                                }
    }
}

I am aslo getting same error.

Thanks Inadvance.
P.Balaji