Expand|Select|Wrap|Line Numbers
- Const OverwriteExisting = True
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- objFSO.CopyFile "\\ftcbank1\databases\Loan Tracking\Installation Files\Loan Tracking.accdb" , "C:\Loan Tracking\", OverwriteExisting
- WScript.Echo EMail( "Loan Tracking <user@company.com>", _
- "Seth Schrock <blank@company.com>", _
- "IT Inventory has been updated.", _
- "This works" & vbCrLf & "xyz", _
- "", _
- "", _
- "Exchange", _
- 25 )
- Function EMail( myFrom, myTo, mySubject, myTextBody, myHTMLBody, myAttachment, mySMTPServer, mySMTPPort )
- set objNet = CreateObject("WScript.NetWork")
- strUserName = objNet.UserName
- ' Standard housekeeping
- Dim i, objEmail
- ' Use custom error handling
- On Error Resume Next
- ' Create an e-mail message object
- Set objEmail = CreateObject( "CDO.Message" )
- ' Fill in the field values
- With objEmail
- .From = strUserName & "@company.com"
- .To = "Blank@company.com"
- .Subject = "Loan Tracking"
- .HTMLBody = "The Loan Tracking database on " & strUserName & "'s computer has been updated"
- If mySMTPPort = "" Then
- mySMTPPort = 25
- End If
- With .Configuration.Fields
- .Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ) = 2
- .Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ) = mySMTPServer
- .Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ) = mySMTPPort
- .Update
- End With
- ' Send the message
- .Send
- End With
- ' Return status message
- If Err Then
- EMail = "ERROR " & Err.Number & ": " & Err.Description
- Err.Clear
- Else
- EMail = "Message sent ok"
- End If
- ' Release the e-mail message object
- Set objEmail = Nothing
- ' Restore default error handling
- On Error Goto 0
- End Function
I read online that the DoCmd.SendObject sends emails using the default email application. In most cases this is Outlook, but the user might not be setup in Outlook so I don't think that this would work.