Merhaba arkadaşlar aşağıdaki kodu kullanarak toplu mail gönderimi yapıyorum. Aşağıdaki koda Outlook’ta tanımlı olan kimden mail adresine göre gönderim yapmak mümkün müdür?
Sub MAIL_GONDER()
Dim Outlook_App As Object
Dim Outlook_Mail As Object
Dim SigString As String
Dim Signature As String
Dim S1 As Worksheet, X As Long
Set Outlook_App = CreateObject("Outlook.Application")
Set S1 = Sheets("Sheet1")
SigString = Environ("appdata") & _
"/Microsoft/Signatures/imza.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
For X = 2 To S1.Cells(S1.Rows.Count, 1).End(3).Row
Set Outlook_Mail = Outlook_App.CreateItem(0)
With Outlook_Mail
.To = S1.Cells(X, 2)
.CC = ""
.Subject = Range("F1") & " [" & S1.Cells(X, 1) & "]"
'.body = Range("G2")
.HTMLBody = "<br>" & Range("F2") & "<br>" & "<br>" & Range("F4") & "<br>" & Range("F6") & "<br>" & Signature
.Attachments.Add S1.Cells(X, 3).Text
.BodyFormat = 2
.Save
'.Send
.Display
End With
Next
Set S1 = Nothing
Set Outlook_Mail = Nothing
Set Outlook_App = Nothing
MsgBox "İşleminiz tamamlanmıştır.", vbInformation
End Sub
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub MAIL_GONDER()
Dim Outlook_App As Object
Dim Outlook_Mail As Object
Dim SigString As String
Dim Signature As String
Dim S1 As Worksheet, X As Long
Set Outlook_App = CreateObject("Outlook.Application")
Set S1 = Sheets("Sheet1")
SigString = Environ("appdata") & _
"/Microsoft/Signatures/imza.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
For X = 2 To S1.Cells(S1.Rows.Count, 1).End(3).Row
Set Outlook_Mail = Outlook_App.CreateItem(0)
With Outlook_Mail
.To = S1.Cells(X, 2)
.CC = ""
.Subject = Range("F1") & " [" & S1.Cells(X, 1) & "]"
'.body = Range("G2")
.HTMLBody = "<br>" & Range("F2") & "<br>" & "<br>" & Range("F4") & "<br>" & Range("F6") & "<br>" & Signature
.Attachments.Add S1.Cells(X, 3).Text
.BodyFormat = 2
.Save
'.Send
.Display
End With
Next
Set S1 = Nothing
Set Outlook_Mail = Nothing
Set Outlook_App = Nothing
MsgBox "İşleminiz tamamlanmıştır.", vbInformation
End Sub
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function