Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel email alert?

Status
Not open for further replies.

Snookless7

Technical User
Feb 18, 2010
28
0
0
US
Hello,

I have been reading previous post regarding automatic email notifications when the document has been changed/saved.

I have tried almost every code I have seen, however I am not that accustomed to VB.

How I enter the scrips is just click on the VB Icon and paste the script in, altering the email of course then saving.

I have tried multiple scripts and this is the one I am using now but yet I get no email after I save??

Code:
Sub SendNotif()

Dim bStarted As Boolean
Dim oOutlookApp As Object
Dim oItem As Object

On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
   'Outlook wasn't running, start it from code
   Set oOutlookApp = CreateObject("Outlook.Application")
   bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(0)

With oItem
   'Set the recipient for the new email
   .To = "QAAlert@test.com"
   'Set the subject
   .Subject = "QUALITY ALERT!!!!"
   'Set the message body
   .Body = "The Reject Log has been updated. Please Check!"
   .Send
End With

If bStarted Then
   'If we started Outlook from code, then close it
   oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub

I know the problem is me...doing something wrong as usual.....but i can not figure this one out.
Using MS Excel Pro Plus 10

Thank you in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top