Question return value from Send Outlook Email?

ccbryan

Active member
Joined
Oct 14, 2008
Messages
30
Programming Experience
5-10
Hi. I'm wondering if it's possible to receive a return value from this function (which runs fine) that indicates whether the email has been successfully sent:

VB.NET:
Public Sub sendOutlookEmail(ByVal strFrom As String, ByVal strTo() _
    As String, ByVal strSubject _
    As String, ByVal strMessage _
    As String, ByVal fileList() As String)
            MailCC = System.Configuration.ConfigurationSettings.AppSettings("MailCC")

            Dim objOutlook As Object
            Dim objOutlookMsg As Object

            Const olMailItem = 0
            Const olBCC = 3
            Const olImportanceHigh = 2
            Const olCC = 2
            Const olTo = 1

            objOutlook = CreateObject("Outlook.Application")
            objOutlookMsg = objOutlook.CreateItem(olMailItem)

            With objOutlookMsg
                Dim objOutlookRecip As Object = .Recipients.Add(strTo(0))
                objOutlookRecip.type = olTo

                Dim int As Integer = 1
                While int < 5
                    If strTo(int) <> "" Then
                        .recipients.add(strTo(int))
                    End If
                    int += 1

                End While
                int = 1
                .sentonbehalfofname = strFrom
                .Subject = strSubject
                .Body = strMessage
                .Importance = olImportanceHigh
                .Attachments.Add(fileList(1))
                .Send() 

            End With
            objOutlookMsg = Nothing
            objOutlook = Nothing

        MsgBox("Email sent")
End Sub

I would greatly appreciate any suggestions!

Thanks,
Chandler
 
Uh... Change the Sub to a Function and return whatever value you wish? Or did I misunderstand the question?
 
Back
Top