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);
}
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", "标题:没事。", "文本:含悲谈笑,笑说人世间。")
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
发表评论