vb outlook发邮件

Posted fighting18

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vb outlook发邮件相关的知识,希望对你有一定的参考价值。

Function SendEmail(ByVal sMail, ByVal sSubject, ByVal sBody, ByVal sCC)

Dim objOutlook As New Outlook.Application
   '定义outlook邮件的对象变量
   Dim objMail As MailItem
Dim strTo As Variant
Dim sptTo() As String
   '创建objOutlook为Outlook应用程序对象
   Set objOutlook = New Outlook.Application
   '创建objMail为一个邮件对象
   Set objMail = objOutlook.CreateItem(olMailItem)
   
   sptTo = Split(sMail, ";")

    With Application
    .EnableEvents = False
    .ScreenUpdating = False
    End With

    With objMail
        .Subject = sSubject
        
        .htmlBody = sBody
                
        For Each strTo In sptTo()
            If Len(Trim(strTo)) <> 0 Then
                .Recipients.Add strTo
                
            End If
        Next
         .CC = sCC
    
        .Display
    End With

    With Application
    .EnableEvents = True
    .ScreenUpdating = True
    End With
End Function

Sub send email()
Dim wb_Marco As Workbook

Dim wsh2 As Worksheet

Dim strMail As Variant, strSubject As String
Dim strBody As String, strOutlook As String
Dim strCC As Variant
Application.ScreenUpdating = False


Set wb_Marco = ThisWorkbook
 

'发送邮件
'Set wsh2 = wb_Marco.Worksheets("Email ")
'    With ActiveSheet
'        strMail = wsh2.Range("B4").Value
'        strSubject = wsh2.Range("B2").Value
'        strBody = wsh2.Range("B3").Value
'    End With
'    SendEmail strMail, strSubject, strBody
'    MsgBox "发送邮件完毕!", vbInformation + vbOKOnly, "提示"

'wb_Source.Close 关闭excel

End Sub

以上是关于vb outlook发邮件的主要内容,如果未能解决你的问题,请参考以下文章

vb outlook发邮件

c#代码怎么通过outlook发邮件

用python调用outlook发邮件的问题

怎么用outlook发邮件

如何在Java ee项目中如何调用outlook发邮件

32 位 VB6 应用程序需要自动化 64 位 Outlook 发送电子邮件而不提示用户