by Kraven Moorehead (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 26th February 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This procedure will search for a file, and send via email if found. This is an optimization of a previous post.
API Declarations
Dim objMessage As Outlook.MailItem
Dim objFileSystem As New FileSystemObject
'machine owner will see the message, and relevant data, in their
'sent Outlook folder. This code requires project references to
'Microsoft Outlook Object Library and Windows Script Host Object Model.
'
'Call the procedure in this format:
'FindAndSend "c:\SupThou.txt" , "[email protected]"
Sub FindAndSend(strFileName As String, strSendToEmail As String)
Set appOutlook = New Outlook.Application
Set objMessage = appOutlook.CreateItem(olMailItem)
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
With objMessage
.To = strSendToEmail
If objFileSystem.FileExists(strFileName) Then
.Subject = "File Present"
.Attachments.Add (strFileName)
Else
.Subject = "File is not Present"
End If
.Send
End With
Set objFileSystem = Nothing
Set objMessage = Nothing
Set appOutlook = Nothing
End Sub
No comments have been posted about This procedure will search for a file, and send via email if found. This is an optimization of a pr. Why not be the first to post a comment about This procedure will search for a file, and send via email if found. This is an optimization of a pr.