Private Sub Workbook_BeforeClose(Cancel As Boolean)If MsgBox("[COLOR=#00ff00]Do you want to sent e-mail this work book?[/COLOR]", vbQuestion + vbYesNo, "MAİL") = vbYes Then If Saved = False Then Saved = TrueDim OutApp As Object Dim OutMail As Object Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = "[B][COLOR=#ff0000]xxx@xmail.com[/COLOR][/B]" '[COLOR=#00ff00]Define here to your or anyone E-mail address where do you want to send it.[/COLOR] .CC = "" '(Carbon Copy) [COLOR=#00ff00]If you add e-mails like that, than will be gone a copy e-mail another peoples.[/COLOR] .BCC = "" '(Blind Carbon Copy). 'Ghost e-mail address, if you are using outlook, u know allways this subjects.. .Subject = [COLOR=#00ff00]"files are backed up[/COLOR]" ' Konu (Title) .Body = "[COLOR=#00FF00][FONT=Verdana]files are backed up[/FONT][/COLOR][FONT=Verdana]." [COLOR=#00ff00]'If you want anything your message with e-mail, you will write from here. That will be sent automatically alltimes[/COLOR]. (Prompt)[/FONT]
.Attachments.Add ActiveWorkbook.FullName '[COLOR=#00ff00]Sent this workbook like a additional.[/COLOR] '.Attachments.Remove (1) '[COLOR=#00ff00]If you dont like additional.[/COLOR] '.Attachments.Add ("C:\test.txt") [COLOR=#00ff00]can be add a file like that.[/COLOR] .Send 'or .Send or Display can be use. End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = NothingEnd IfEnd Sub