ifenton
asked on
How do I use MAPI to send an email alert
I want to send alerts automatically from windows. For example in Performance Logs and Alerts, when the processer hits 90% the alert will trigger and sends an email to a user. I know that using MAPI should be the way to do this but I don't know a thing about MAPI. Any help would be appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Let me know if you need full examples of the performance monitoring and the MAPI stuff and I can provide them.
Function SendEmail(xAddress, xSubject, xText, ByVal xAttachments)
' "xAttachments" - tablou unidimensional:
' lista fisierelor atasate.
Dim objSession As Object, objMessage As Object
Dim objOneRecip As Object
Dim i As Integer
On Error GoTo error_sendMsg
Set objSession = CreateObject("MSMAPI.MAPIS
objSession.SignOn
Set objMessage = CreateObject("MSMAPI.MAPIM
objMessage.SessionID = objSession.SessionID
objMessage.Compose
objMessage.MsgIndex = -1
objMessage.RecipAddress = xAddress
objMessage.AddressResolveU
objMessage.MsgSubject = xSubject
objMessage.MsgNoteText = xText
If IsArray(xAttachments) Then
For i = 0 To UBound(xAttachments)
objMessage.AttachmentIndex
objMessage.AttachmentPathN
Next
End If
objMessage.Send False
objSession.SignOff
On Error GoTo 0
SendEmail = True
Exit Function
error_sendMsg:
On Error GoTo 0
SendEmail = False
End Function