美文网首页
B4A_安卓 通过SMTP电子邮件

B4A_安卓 通过SMTP电子邮件

作者: 丽_0173 | 来源:发表于2020-01-16 20:04 被阅读0次

    SMTP电子邮件


    B4A安卓




    SMTP示例效果图示

    01.邮箱设置

    >>>>

    QQ邮箱设置stmp,见下图!然后按提示操作即可!


    >>>>

    163邮箱设置stmp,见下图!然后按提示操作即可!


    02.界面设计

    >>>>

    首先引用NET类库

    >>>>

    设计界面布局



    03.代码书写

    #Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #End Region

    #Region Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
    #End Region

    Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

    End Sub

    Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private but_send As Button
    Private txt_arc As AutoCompleteEditText
    Private txt_title As EditText
    Private txt_toadd As EditText
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("test")

    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub


    Sub but_send_Click

    ''引用NET类库

    Dim SMTP_Mail As SMTP

    'SMTP_Mail.Initialize("smtp.qq.com",587, "*****@qq.com","**********","SMTP")

    SMTP_Mail.Initialize("smtp.163.com",25, "*********@163.com","*******","SMTP") ''邮件发出的地址

    SMTP_Mail.UseSSL = False ''是否使用SSL

    SMTP_Mail.StartTLSMode=True ''启用TLS模式

    SMTP_Mail.AuthMethod=SMTP_Mail.AUTH_LOGIN ''登录验证方式

    SMTP_Mail.To.Add(txt_toadd.Text) ''接收的邮件

    SMTP_Mail.Subject = txt_title.Text ''邮件标题

    SMTP_Mail.Body =txt_arc.Text ''邮件主题内容

    'SMTP_Mail.AddAttachment(File.DirDefaultExternal,"test.txt") ''邮件附件

    SMTP_Mail.Send ''发送邮件

    Wait For SMTP_MessageSent(Success As Boolean)

    If Success=True Then

    ToastMessageShow("邮件发送成功!",False)

    Else

    ToastMessageShow("邮件发送失败!",False)

    End If


    End Sub
        
    

    往期精彩回顾

    VB.NET 发送QQ邮件,可用于发送验证码和批量文件,通知信息


    相关文章

      网友评论

          本文标题:B4A_安卓 通过SMTP电子邮件

          本文链接:https://www.haomeiwen.com/subject/mflqzctx.html