`

android gmail send email

 
阅读更多

package org.apache.android.mail; 
 
import android.app.Activity; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
 
public class SendMail extends Activity { 
    /**
     * Called with the activity is first created.
     */ 
    @Override 
    public void onCreate(Bundle icicle) { 
        super.onCreate(icicle); 
        setContentView(R.layout.main); 
        final Button send = (Button) this.findViewById(R.id.send); 
        final EditText userid = (EditText) this.findViewById(R.id.userid); 
        final EditText password = (EditText) this.findViewById(R.id.password); 
        final EditText from = (EditText) this.findViewById(R.id.from); 
        final EditText to = (EditText) this.findViewById(R.id.to); 
        final EditText subject = (EditText) this.findViewById(R.id.subject); 
        final EditText body = (EditText) this.findViewById(R.id.body); 
        send.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View view) { 
                GMailSender sender = new GMailSender(userid.getText().toString(),
                    password.getText().toString()); 
                try { 
                    sender.sendMail(subject.getText().toString(), 
                            body.getText().toString(), 
                            from.getText().toString(), 
                            to.getText().toString()); 
                } catch (Exception e) { 
                    Log.e("SendMail", e.getMessage(), e); 
                } 
            } 
        }); 
    } 
}

分享到:
评论

相关推荐

    android自动发送Email

    Transport.send(message); Log.d("Email", "邮件发送成功"); } catch (MessagingException e) { e.printStackTrace(); Log.e("Email", "邮件发送失败:" + e.getMessage()); } ``` 请注意,为了防止泄露敏感信息...

    android 发送email所需jar包

    创建`Transport`对象并调用其`send()`方法发送邮件。 ```java Transport transport = session.getTransport("smtp"); transport.connect(host, username, password); transport.sendMessage(message, message....

    Android应用源码之AndroidEmail(邮件收发)_收发.zip

    这个名为"Android应用源码之AndroidEmail(邮件收发)_收发.zip"的压缩包文件很可能包含了一个完整的示例项目,用于展示如何在Android应用程序中集成邮件功能。让我们深入探讨一下Android邮件收发的基本原理和实现方法...

    Android 发送电子邮件 EMAIL 源码

    以下是对这个"Android发送电子邮件EMAIL源码"的详细解析。 首先,我们需要理解Android系统中发送邮件的基本流程。这通常涉及到以下几个步骤: 1. **构建邮件消息对象**:在Android中,我们使用`java.mail`库(通过...

    GmailAPI:使用Gmail API发送电子邮件

    GmailAPI 使用Gmail API发送电子邮件该存储库演示了如何使用Google的Gmail API重要通知GoogleNetHttpTransport.newTrustedTransport()不能按文档使用,而是使用AndroidHttp.newCompatibleTransport()来避免常规安全...

    Email-Android

    使用`android.intent.action.SEND` Intent,开发者可以启动一个系统级的分享对话框,让用户选择邮件应用来发送带有附件的邮件。发送邮件时,需要设置Intent的数据类型(如`"text/plain"`或`"text/html"`),并添加收...

    安卓 邮件发送 android email

    接着,使用`Transport`类的`send()`方法发送邮件。代码示例: ```java Properties props = new Properties(); props.put("mail.smtp.host", smtpHost); props.put("mail.smtp.port", smtpPort); props.put(...

    android 下用org.apache.commons.mail.HtmlEmail发送邮件所需的jar包

    email.send(); } catch (EmailException e) { e.printStackTrace(); } ``` 请注意,由于Android的安全限制,直接在设备上使用SMTP发送邮件可能需要处理权限问题。在Android 6.0及以上版本,你可能需要请求`...

    Android使用Javamail发送Email群发加附件

    在Android应用开发中,有时需要实现自定义的邮件发送功能,而不是依赖系统内置的邮件客户端。本篇文章将详细介绍如何使用JavaMail API在Android中发送带有附件并进行群发的电子邮件。首先,我们需要理解JavaMail API...

    Android开发中怎样调用系统Email发送邮件(多种调用方式)

    总的来说,Android开发中调用系统Email发送邮件主要依赖于Intent,通过ACTION_SENDTO、ACTION_SEND和ACTION_SEND_MULTIPLE三种Intent类型,我们可以根据实际需求灵活地发送各种类型的邮件。同时,别忘了在使用Intent...

    基于Android的邮件收发

    store.connect("imap.gmail.com", "yourEmail@gmail.com", "yourPassword"); Folder inbox = store.getFolder("INBOX"); inbox.open(Folder.READ_ONLY); ``` 之后,你可以遍历inbox中的Message对象,获取邮件的...

    android邮件发送客户端代码

    emailService.sendEmail("from-email@example.com", "to-email@example.com", "Test Email", "This is a test email sent from Android app."); ``` 对于163和QQ邮箱,你需要查找相应的SMTP服务器设置并替换上述...

    Android调用谷歌STMP发送邮件

    在这段代码中,`GMAIL_USERNAME`和`GMAIL_PASSWORD`是你的Gmail账户信息,`RECIPIENT_EMAIL`是收件人邮箱地址,`SUBJECT`和`BODY`分别是邮件的主题和正文。 4. **处理权限问题**: 自Android 6.0(API级别23)...

    email tools

    常见的Android邮件客户端如Gmail、Yahoo Mail、Outlook等,它们提供了用户友好的界面和高效的工作流程。开发者在构建自定义邮件应用时,需要考虑SSL/TLS加密以保证通信安全,同时支持IMAP、POP3和SMTP协议来获取和...

    android-mail.jar

    Transport.send(message); ``` 在实际开发中,需要注意以下几点: - Gmail和其他邮件服务提供商可能需要开启"允许不够安全的应用"的设置才能使用SMTP。 - 需要处理各种异常情况,例如网络问题、服务器拒绝连接等。 ...

    Android自带的邮件发送代码

    return new PasswordAuthentication("your-email@gmail.com", "your-password"); } }); ``` 在上面的代码中,我们设置了Gmail的SMTP服务器,启用了TLS加密,并提供了认证信息。如果你使用其他邮件服务提供商,...

    Android代码-Android-Rest-Client

    This is a GPL implementation of a basic REST client API ... Send me an email at LinuxMercedes@gmail.com if you want to help. Todo: Lots of testing Add support for insecure SSL certificates. ??? Profit!

    Android实现发送邮件

    7. **发送邮件**:最后,通过`Transport`类的`send()`方法,将`MimeMessage`对象发送出去。如果使用了SSL/TLS,需要先调用`Transport`的`connect()`方法,传入SMTP服务器地址和指定的端口,然后才能发送邮件。 8. *...

    Android代码-Android—CSV-Contacts-Import

    README This is my first Android Open Source project. Please contact me at sparks.code@gmail.com The source is available at:... So send any bug report to the above email.

    android app发送错误报告到邮箱

    emailSender.sendEmail("Error Report", errorBody, "your-email@gmail.com", "developer-email@example.com", "your-password"); } ``` 注意,如果你使用Gmail SMTP服务器,确保已启用“不太安全的应用”的访问...

Global site tag (gtag.js) - Google Analytics