adventurous26
Altın Üye
- Katılım
- 20 Haziran 2013
- Mesajlar
- 301
- Excel Vers. ve Dili
- EXCELL 365
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Function SendActiveWorkbook(strTo As String, strSubject As String, Optional strCC As String, Optional strBody As String) As Boolean
On Error Resume Next
Dim appOutlook As Object
Dim mItem As Object
'create a new instance of Outlook
Set appOutlook = CreateObject("Outlook.Application")
Set mItem = appOutlook.CreateItem(0)
With mItem
.To = strTo
.CC = ""
.Subject = strSubject
.Body = strBody
.Attachments.Add ActiveWorkbook.FullName
'use send to send immediately or display to show on the screen
.Display 'or .Send
End With
'clean up objects
Set mItem = Nothing
Set appOutlook = Nothing
End Function
Sub SendMail()
Dim strTo As String
Dim strSubject As String
Dim strBody As String
'populate variables
strTo = "jon.smith@gmail.com"
strSubject = "Please find finance file attached"
strBody = "some text goes here for the body of the email"
'call the function to send the email
If SendActiveWorkbook(strTo, strSubject, , strBody) = True Then
MsgBox "Email creation Success"
Else
MsgBox "Email creation failed!"
End If
End Sub