DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
'******************************************************
'* Sadece Aktif sayfayı MS Outlook ile yollamak için *
'* yapılmış bir çalışmadır *
'* Micosoft Outlook X.0 referansı eklenmelidir ! *
'* Burası Excel vadisi ... *
'* Raider ® *
'* Subat 2005 *
'******************************************************
Sub SendShByEmail()
Dim OutApp As Outlook.Application
Dim NewMail As Outlook.MailItem
Dim ShName As String, WbName As String
Dim i As Integer
Dim ModX As Object, VBComp As Object
ShName = ActiveSheet.Name
WbName = "C:\" & ShName & ".xls"
ThisWorkbook.SaveCopyAs WbName
Application.DisplayAlerts = False
Workbooks.Open WbName
For i = Sheets.Count To 1 Step -1
If ActiveWorkbook.Sheets(i).Name <> ShName Then Sheets(i).Delete
Next
On Error Resume Next
For Each ModX In ActiveWorkbook.VBProject.VBComponents
Set VBComp = ActiveWorkbook.VBProject.VBComponents(ModX.Name)
ActiveWorkbook.VBProject.VBComponents.Remove VBComp
Next
On Error GoTo 0
Application.DisplayAlerts = True
ActiveWorkbook.Close SaveChanges:=True
Set OutApp = New Outlook.Application
Set NewMail = CreateItem(olMailItem)
With NewMail
.To = "falan@filan.com"
.Subject = "Deneme"
.Body = "Bu e-mail deneme amacıyla gönderilmiştir."
.Attachments.Add WbName
.Save
.Send
End With
Set NewMail = Nothing
Set OutApp = Nothing
Set VBComp = Nothing
Kill WbName
End Sub
Private Sub CommandButton2_Click()
'******************************************************
'* Sadece Aktif sayfayı MS Outlook ile yollamak için *
'* yapılmış bir çalışmadır *
'* Micosoft Outlook X.0 referansı eklenmelidir ! *
'* Burası Excel vadisi ... *
'* Raider ® *
'* Subat 2005 *
'******************************************************
'<<<<<<<<<<<<<<<<<<<<<<<KONTROLLER>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'Aktif internet bağlantısı varmı kontrol et.
If TestInternetConnection = False Then
MsgBox "BAĞLANTI YOK": Exit Sub
End If
'Micosoft Outlook X.0 referansı yoksa ekler....
Dim bool As Boolean
strRefPath = "C:\Program Files\Microsoft Office\OFFICE11\msoutl.olb" 'ADO
bool = False
For Each ref In ThisWorkbook.VBProject.References
If ref.fullPath = strRefPath Then bool = True
Next
If bool = False Then ThisWorkbook.VBProject.References.AddFromFile (strRefPath)
'Nesne Kontrol
For Each nsn In Controls
If TypeName(nsn) = "TextBox" Then ' NESNENIN ADI YAZILACAK
If nsn.Value = "" Then
aa = Replace(nsn.Name, "txt", "lbl")
MsgBox Controls(aa).Caption & " Textboxu Boş Bırakılamaz!"
nsn.SetFocus: Exit Sub
End If
End If
Next nsn
'MsgBox "kontroller tamamlandı.": Exit Sub
'<<<<<<<<<<<<<<<<<<<<<<<İŞLEMLER>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Dim OutApp As Outlook.Application
Dim NewMail As Outlook.MailItem
Dim ShName As String, WbName As String
Dim i As Integer
' Aktif Sayfayı yeni kitaba kopyala ve kapat
ShName = ActiveSheet.Name: Sheets(ShName).Copy
WbName = "C:\" & ShName & ".xls": ActiveWorkbook.SaveAs WbName
Workbooks(ShName & ".xls").Close SaveChanges:=True
'Oluşturulan kitabı e-mail ile gönder
Set OutApp = New Outlook.Application
Set NewMail = CreateItem(olMailItem)
StrKime = txtKime.Value
strKonu = txtKonu.Value
strMsj = txtMsj.Value
With NewMail
.To = StrKime '"xxxxx@hotmail.com"
.Subject = strKonu '"Deneme"
.Body = strMsj '"Bu e-mail deneme amacıyla gönderilmiştir."
.Attachments.Add WbName
.Save
.Send
End With
'Tamamlandı mesajı:
MsgBox StrKime & " adresine" & ShName & " sayfası gönderildi."
'oluşturulmuş değişşken ve dosyaları sil....
Set NewMail = Nothing: Set OutApp = Nothing
Kill WbName
End Sub
Sub AktifSayfayıGonder()
'******************************************************
'* Sadece Aktif sayfayı MS Outlook ile yollamak için *
'* yapılmış bir çalışmadır *
'* Micosoft Outlook X.0 referansı eklenmelidir ! *
'* Burası Excel vadisi ... *
'* Raider ® *
'* Subat 2005 *
'******************************************************
'<<<<<<<<<<<<<<<<<<<<<<<KONTROLLER>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'Aktif internet bağlantısı varmı kontrol et.
If TestInternetConnection = False Then
MsgBox "BAĞLANTI YOK": Exit Sub
End If
'Micosoft Outlook X.0 referansı yoksa ekler....
' Dim bool As Boolean
' strRefPath = "C:\Program Files\Microsoft Office\OFFICE11\msoutl.olb" 'ADO
' bool = False
' For Each ref In ThisWorkbook.VBProject.References
' If ref.fullPath = strRefPath Then bool = True
' Next
' If bool = False Then ThisWorkbook.VBProject.References.AddFromFile (strRefPath)
'MsgBox "kontroller tamamlandı.": Exit Sub
'<<<<<<<<<<<<<<<<<<<<<<<İŞLEMLER>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Dim OutApp As Outlook.Application
Dim NewMail As Outlook.MailItem
Dim ShName As String, WbName As String
Dim i As Integer
' Aktif Sayfayı yeni kitaba kopyala ve kapat
ShName = ActiveSheet.Name: Sheets(ShName).Copy
WbName = "C:\" & ShName & ".xls": ActiveWorkbook.SaveAs WbName
Workbooks(ShName & ".xls").Close SaveChanges:=True
'Oluşturulan kitabı e-mail ile gönder
Set OutApp = New Outlook.Application
Set NewMail = CreateItem(olMailItem)
[B] StrKime = "xxxxxxxxxx@yyyyy.zzz"
strKonu = "Deneme2136_modul"
strMsj = "Bu e-mail deneme amacıyla gönderilmiştir."[/B]
With NewMail
.To = StrKime '"xxxxx@hotmail.com"
.Subject = strKonu '"Deneme"
.Body = strMsj '"Bu e-mail deneme amacıyla gönderilmiştir."
.Attachments.Add WbName
.Save
.Send
End With
'Tamamlandı mesajı:
MsgBox StrKime & " adresine " & ShName & " sayfası gönderildi."
'oluşturulmuş değişşken ve dosyaları sil....
Set NewMail = Nothing: Set OutApp = Nothing
Kill WbName
End Sub
Option Private Module
Declare Function InternetCheckConnection Lib "wininet.dll" _
Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, _
ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
(ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, _
ByVal dwNameLen As Integer, ByVal dwReserved As Long) As Long
'
Dim RunWhen As Double
Const RunWhat = "CheckInternetState"
'
Sub Auto_Open()
Call CheckInternetState
End Sub
'
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 5, 0)
Application.OnTime earliesttime:=RunWhen, Procedure:=RunWhat, Schedule:=True
End Sub
'
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, Procedure:=RunWhat, Schedule:=False
End Sub
'
Sub Auto_Close()
Call StopTimer
End Sub
'
Sub CheckInternetState()
Dim RetVal As Long
Dim strConn As String * 255
' Range("A1") = Empty
' Range("B1") = "Checking ...."
If TestInternetConnection = True Then
' Range("A1") = TestInternetConnection
RetVal = InternetGetConnectedStateEx(RetVal, strConn, 254, 0)
' Range("B1") = strConn
Call StopTimer
Exit Sub
End If
'Range("A1") = TestInternetConnection
'Range("B1") = "No connection !"
Call StartTimer
End Sub
'
Function TestInternetConnection() As Boolean
'Adapted from :
'KPD-Team 2001
'URL: http://www.allapi.net/
If (InternetCheckConnection("http://www.allapi.net/", &H1, 0&) = 0) Then
TestInternetConnection = False
Else
TestInternetConnection = True
End If
End Function
O mesajda belirtildiğiüzere, kodların yer aldığı dosyaya ilgili "Micosoft Outlook X.0 referansı eklenmelidir !"
Daha sonra dosyayı kaydedip, makroyu çalıştırın.
Verdiğim linkteki kodların okunabilirliğini düzeltmek için burada tekrar veriyorum.
Kod:'****************************************************** '* Sadece Aktif sayfayı MS Outlook ile yollamak için * '* yapılmış bir çalışmadır * '* Micosoft Outlook X.0 referansı eklenmelidir ! * '* Burası Excel vadisi ... * '* Raider ® * '* Subat 2005 * '****************************************************** Sub SendShByEmail() Dim OutApp As Outlook.Application Dim NewMail As Outlook.MailItem Dim ShName As String, WbName As String Dim i As Integer Dim ModX As Object, VBComp As Object ShName = ActiveSheet.Name WbName = "C:\" & ShName & ".xls" ThisWorkbook.SaveCopyAs WbName Application.DisplayAlerts = False Workbooks.Open WbName For i = Sheets.Count To 1 Step -1 If ActiveWorkbook.Sheets(i).Name <> ShName Then Sheets(i).Delete Next On Error Resume Next For Each ModX In ActiveWorkbook.VBProject.VBComponents Set VBComp = ActiveWorkbook.VBProject.VBComponents(ModX.Name) ActiveWorkbook.VBProject.VBComponents.Remove VBComp Next On Error GoTo 0 Application.DisplayAlerts = True ActiveWorkbook.Close SaveChanges:=True Set OutApp = New Outlook.Application Set NewMail = CreateItem(olMailItem) With NewMail .To = "falan@filan.com" .Subject = "Deneme" .Body = "Bu e-mail deneme amacıyla gönderilmiştir." .Attachments.Add WbName .Save .Send End With Set NewMail = Nothing Set OutApp = Nothing Set VBComp = Nothing Kill WbName End Sub