안드로이드 개발 질문/답변
(글 수 45,052)
일단 Commons-Email.jar과 JavaMail의 mail.jar와 JAF의 activation.jar 이 3가지를 다운 받았습니다.
그런데.. 외부 jar을 추가하는데 엄청난 양의 warning이 나옵니다..
warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.)
이렇게요...그리곤 실행하면 앱이 강제종료 되죠..
그래서 혹시 몰라 그냥 자바 프로젝트를 만들어서 테스트 해보았습니다.
jar 추가도 잘되고.. 메일도 잘 보내지더군요..-_-;;
도대체 안드로이드에선 왜 안되는 것일까요..
로그를 보니까 클래스들을 못찾더라고요.. 제 생각인데.. jar 추가에서 문제가 있는듯 한데요..
소스와 로그도 올립니다. 도와주세요 ㅠㅠ
package com.test;
import org.apache.commons.mail.*;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
public class EmailTest_with_Attachment_Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.Button01);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
EmailAttachment attchment = new EmailAttachment();
attchment.setPath("file://"+Environment.getExternalStorageDirectory()+"/ssk.jpg");
attchment.setDisposition(EmailAttachment.ATTACHMENT);
attchment.setDescription("Picture of SSK");
attchment.setName("ssk.jpg");
MultiPartEmail email = new MultiPartEmail();
email.setCharset("euc-kr");
email.setHostName("메일서버주소");
email.setAuthentication("계정", "아이디");
try {
email.addTo("수신자주소", "이름");
email.setFrom("발신자주소");
email.setSubject("Send Picture");
email.setMsg("Email Test with Attachment.");
email.attach(attchment);
email.send();
} catch (EmailException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// MailSender mySender = new MailSender();
}
});
}
}
// 물론 위에 한글로 써진 부분은 다 제대로 채워 넣었습니다.



만약 라이브러리가 오픈 소스라면 안드로이드로 재빌드 하는것을 추천해 드리구요.
적어도 빌드를 UTF-8 기반으로 하는 것도 방법이 될 수 있습니다.
자바이긴 하지만 자바가 아닌게 안드로이드입니다. ㅡㅡㅋ 뭔가 미묘하게 안되는 부분들이 나오더라구요 라이브러리를 가져다 쓰믄...