Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!
Private Sub SendEmail(strEmailAdd As String, strFrom As String, strBody As String, _ strSubject As String, strCc As Variant, strBcc As Variant) On Error GoTo errHandler Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment Dim objOutlookFrom As Outlook.MailItem Dim objOutlookInbox As Outlook.MAPIFolder ' Create the Outlook session. Set objOutlook = CreateObject("Outlook.Application") ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) With objOutlookMsg ' Set sender .SentOnBehalfOfName = strFrom ' Add the To recipient(s) to the message. This can be a variable or pulled form a table if desired. Set objOutlookRecip = .Recipients.Add(strEmailAdd) objOutlookRecip.Type = olTo ' Add the Cc recipient(s) to the message. If Not ISNULL(strCc) Then .CC = strCc End If ' Add the Bcc recipient(s) to the message. If Not ISNULL(strBcc) Then .BCC = strBcc End If ' Set the Subject, Body, and Importance of the message. .Subject = strSubject .HTMLBody = strBody .Importance = olImportanceNormal 'Normal importance ' Resolve each Recipient's name. For Each objOutlookRecip In .Recipients objOutlookRecip.Resolve Next If Not .Recipients.ResolveAll Then For Each objOutlookRecip In .Recipients If Not objOutlookRecip.Resolved Then MsgBox "Error on e-mail name " & objOutlookRecip & ". I will open the e-mail so you can correct it before you send it." End If Next .Display Else: .Save .Send End If End With exitHere: Set objOutlook = Nothing Exit Sub errHandler: Select Case Err Case Else MsgBox "Error Number: " & Err.Number & vbNewLine & "Description: " & Err.Description, vbCritical, "Error" GoTo exitHere End Select End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.