Android 之APP程序崩溃后,自动向QQ 邮箱发送邮件


    private void sendAppCrashReport(final Context context, final String crashReport, final String file) { 
    	
    	  try 
          { 
           MailSenderInfo mailInfo = new MailSenderInfo();    
           mailInfo.setMailServerHost("smtp.qq.com");    
           mailInfo.setMailServerPort("25");    
           mailInfo.setValidate(true);    
           mailInfo.setUserName("[email protected]");  //你的邮箱地址  
           mailInfo.setPassword("xxxx");//您的邮箱密码    
           mailInfo.setFromAddress("[email protected]");    
           mailInfo.setToAddress("[email protected]");    
           mailInfo.setSubject("程序异常");    
           mailInfo.setContent(crashReport);    
           
              //这个类主要来发送邮件   
           SimpleMailSender sms = new SimpleMailSender();   
           String file1=Environment.getExternalStorageDirectory().getAbsolutePath()+ "/dbqst/qst.db";
             sms.sendTextMail(mailInfo,file1);//发送文体格式    
             //sms.sendHtmlMail(mailInfo);//发送html格式 

          } 
          catch (Exception e) { 
              Log.e("SendMail", e.getMessage(), e); 
          }
    	 
    }  

猜你喜欢

转载自yingang-1982.iteye.com/blog/2089959