How to add the Mail Notification for one Macro

venkatesh Sarivisetty
venkatesh Sarivisetty used Ask the Experts™
on
Hi,

We have a macro which will use many sheets to prepare a final report . However at the end of the completion, it should trigger a mails as completed. How to add that ?

Thanks
Venkatesh.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
Hi,

pls try
Sub Mail_Notification()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strbody = "Hi, " & vbcrlf &"The process is finished" & vbcrlf & vbcrlf & "Regards"

    On Error Resume Next
    With OutMail
        .To = "john.doe@mymail.com"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject"
        .Body = strbody
        .Display   'or use .Send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Open in new window


in your code

Sub yourMacro()
'First your code
Call Mail_Notification
End Sub

Open in new window

Regards
venkatesh SarivisettySenior Software Engineer

Author

Commented:
Please share the complete code at once and share me. Also where I will kept this one. Because as I told it is using 3 different files. Please advise.
Top Expert 2016

Commented:
What do you mean?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

venkatesh SarivisettySenior Software Engineer

Author

Commented:
I mean to say, where I need to copy this becoz it is using so many sheets, how to make as a seperate one. Please advise.

Thansk
Venkatesh.
Top Expert 2016

Commented:
Sorry can't help further
TracyVBA Developer

Commented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Rgonzo1971 (https:#a42350936)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

broomee9
Experts-Exchange Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial