Does the file exist:
VB Code:
Function FileExist(ByVal strPath As String) As Boolean
FileExist = Len(Dir$(strPath)) <> 0
end Function
E-mail using Outlook:
VB Code:
'Reference Microsoft Outlook 9.0 Object Library (msoutl9.olb)
Private Sub Email_Click()
Dim olapp As New Outlook.Application
Dim olMail As Outlook.MailItem
Dim myAttachment As Outlook.Attachments
'Create a new mail object
Set olMail = olapp.CreateItem(olMailItem)
Set myAttachment = olMail.Attachments
myAttachment.Add "C:\text.txt"
olMail.Subject = “Testing a send of a message”
olMail.Body = "Hello, this is the body"
olMailsend
Set olMail = Nothing
Set olapp = Nothing
End Sub
But if you don't have Outlook, you might need to use something else, like MAPI:
VB Code:
'need a MAPI control on the form somewhere
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID
frmMonitor.MAPIMessages1.Compose
frmMonitor.MAPIMessages1.MsgSubject = "My Subject"
frmMonitor.MAPIMessages1.MsgNoteText = "My body"
frmMonitor.MAPIMessages1.AttachmentPathName = sAttachment1
frmMonitor.MAPIMessages1.ResolveName
frmMonitor.MAPIMessages1.Send
frmMonitor.MAPISession1.SignOff