20
2012
08

icePubDll应用.发送邮件函数

  • windows os;vc6/vb6;icePubDll.dll;

步骤/方法

  1. VC sample 代码:
    {
    typedef int (WINAPI ICEPUB_SENDMAILTEXT)(char *strUsername,char *strPassword,char *strSmtpServer,char *sendMail,char *toMailList,char *strSubject,char *strText);
    ICEPUB_SENDMAILTEXT *icePub_sendMailText = 0;
    HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
    if(hDLLDrv)
    {
    icePub_sendMailText = (ICEPUB_SENDMAILTEXT *)GetProcAddress(hDLLDrv, "icePub_sendMailText");
    }
    if(icePub_sendMailText)
    icePub_sendMailText("ahuinuli","112233","smtp.tom.com","ahuinuli@tom.com","mike@sina.com","标题:还好么?","文本:扉心祈梦,梦语问春天。");
    if(hDLLDrv)
    FreeLibrary(hDLLDrv);
    }
  2. VB sample 代码:
    Private Declare Function icePub_sendMailText Lib "icePubDll.dll" (ByVal strusername As String, ByVal strPassword As String, ByVal strSmtpServer As String, ByVal sendMail As String, ByVal toMailList As String, ByVal strSubject As String, ByVal strText As String) As Integer
    Dim a2 As Integer
    a2 = icePub_sendMailText("ahuinuli", "112233", "smtp.tom.com", "ahuinuli@tom.com", "tomail@sina.com", "标题:没事。", "文本:含悲谈笑,笑说人世间。")
  3. VB具体步骤:
    界面布局设计
     
    icePubDll应用.发送邮件函数
  4. Private Declare Function icePub_sendMailText Lib "icePubDll.dll" (ByVal strusername As String, ByVal strPassword As String, ByVal strSmtpServer As String, ByVal sendMail As String, ByVal toMailList As String, ByVal strSubject As String, ByVal strText As String) As Integer
    Private Sub Command1_Click()‘退出按钮代码
    Unload Me
    End Sub
    Private Sub Command2_Click()'邮件发送按钮代码
    Dim a As Integer
    Dim str1 As String
    Dim mailCounts As Integer
    str1 = ""
    mailCounts = Val(Text8)’重复次数文本框值
    If mailCounts <= 0 Then
    mailCounts = 1
    End If
    If Text1 = "" Or Text2 = "" Or Text3 = "" Or Text5 = "" Or Text6 = "" Or Text7 = "" Then
    MsgBox "请填好数据~"
    Exit Sub
    End If
    'Text1 发件人邮箱地址文本框值
    'Text2 收件人邮箱地址隔文本框值,多个以分号分
    'Text3 标题文本框值
    'Text4 文本内容文本框值
    'Text5 smtp服务器文本框值
    'Text6 smtp用户名文本框值
    'Text7 用户密码文本框值
    Command2.Enabled = False
    For i = 1 To mailCounts
    a = icePub_sendMailText(Text6, Text7, Text5, Text1, Text2, Text3, Text4)
    If a <> 0 Then
    str1 = str1 + "错误[" + Str(i) + "]errCode=" + Str(a) + vbCrLf
    End If
    DoEvents
    Next i
    Command2.Enabled = True
    If str1 = "" Then
    MsgBox "发送成功"
    Else
    MsgBox "发送失败~" + vbCrLf + str1
    End If
    End Sub
    Private Sub Form_Load()
    ChDrive App.Path
    ChDir App.Path
    End Sub
  5. 运行界面:
     
    icePubDll应用.发送邮件函数

注意事项

  • 函数原型:
    int WINAPI icePub_sendMailText(char *strUsername,char *strPassword,char *strSmtpServer,char *sendMail,char *toMailList,char *strSubject,char *strText)
    输入:strUsername smtp用户名
    strPassword 用户密码
    strSmtpServer smtp服务器
    sendMail 发件人邮箱地址
    toMailList 收件人邮箱地址,多个以分号分隔
    strSubject 标题
    strText 文本内容
    输出:
  • 不支持gmail之类…

 收钱码.jpg

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。