'请参考一下:
Public Function SendMail(Sendto As String, Subject As String, _
Text As String, AttachPath As String, AttachName As String) As BooleanDim olapp As New Outlook.Application
Dim oitem As MailItemDim SubKey As String, ValueName As String
Dim Data As Long, Result As Long
Dim ret As Long
frmMain.lblStatus.Caption = "正在连结Internet ..."
SubKey = "System\CurrentControlSet\Services\RemoteAccess"
ret = RegOpenKey(HKEY_LOCAL_MACHINE, SubKey, Result)
If ret = 0& Then
ValueName = "Remote Connection"
re:
ret = RegQueryValueEx(Result, ValueName, 0&, 0&, ByVal Data, 0&)
ret = RegQueryValueEx(Result, ValueName, 0&, 0&, Data, Len(Data))
If ret = 0& And Data <> 0 Then
'MsgBox "在线!"
Else
'MsgBox "当前未连接。"
InternetAutodial INTERNET_AUTODIAL_FORCE_UNATTENDED, 0
GoTo re:
End If
RegCloseKey (Result)
End IffrmMain.lblStatus.Caption = "正在连结发送邮件 ..."
Set oitem = olapp.CreateItem(0)
With oitem
.Subject = Subject '//邮件主题
.To = Sendto '//收件人
.Body = Text '//邮件正文
.Attachments.Add AttachPath, , , AttachName
.Send '//发送邮件
End WithIf Err.Number = 0 Then
SendMail = True
Else
MsgBox Err.Description
SendMail = False
End If
End Function
Public Function SendMail(Sendto As String, Subject As String, _
Text As String, AttachPath As String, AttachName As String) As BooleanDim olapp As New Outlook.Application
Dim oitem As MailItemDim SubKey As String, ValueName As String
Dim Data As Long, Result As Long
Dim ret As Long
frmMain.lblStatus.Caption = "正在连结Internet ..."
SubKey = "System\CurrentControlSet\Services\RemoteAccess"
ret = RegOpenKey(HKEY_LOCAL_MACHINE, SubKey, Result)
If ret = 0& Then
ValueName = "Remote Connection"
re:
ret = RegQueryValueEx(Result, ValueName, 0&, 0&, ByVal Data, 0&)
ret = RegQueryValueEx(Result, ValueName, 0&, 0&, Data, Len(Data))
If ret = 0& And Data <> 0 Then
'MsgBox "在线!"
Else
'MsgBox "当前未连接。"
InternetAutodial INTERNET_AUTODIAL_FORCE_UNATTENDED, 0
GoTo re:
End If
RegCloseKey (Result)
End IffrmMain.lblStatus.Caption = "正在连结发送邮件 ..."
Set oitem = olapp.CreateItem(0)
With oitem
.Subject = Subject '//邮件主题
.To = Sendto '//收件人
.Body = Text '//邮件正文
.Attachments.Add AttachPath, , , AttachName
.Send '//发送邮件
End WithIf Err.Number = 0 Then
SendMail = True
Else
MsgBox Err.Description
SendMail = False
End If
End Function
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货