- Katılım
- 18 Kasım 2011
- Mesajlar
- 406
- Excel Vers. ve Dili
- excel 2016 türkçe
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Hocam bilgim o kadar yeterli değil ekleyebileceğiniz var mı acaba?
Hocam dosya 1. mesajda ekli...
Dim OutApp As Object, OutMail As Object
Dim Alan As Range, son As Long, Veri As Range
Dim k As Range
Sub mail_gonder()
Set shmail = Sheets("MailGönder")
mailsonsatir = shmail.Cells(Rows.Count, "B").End(3).Row
Sheets("NotAnalizi").Select
sonsatir = Cells(Rows.Count, "B").End(3).Row
Set OutApp = CreateObject("Outlook.Application")
For j = 4 To mailsonsatir
mailadresi = shmail.Cells(j, "D").Value
If mailadresi = "" Or InStr(mailadresi, "@") = 0 Then GoTo son
mailogrenci = shmail.Cells(j, "B").Value
Set k = Range("B1:B" & sonsatir).Find(mailogrenci, , xlValues, xlWhole)
satir = 0
If k Is Nothing Then
Else
satir = k.Row
End If
Set OutMail = OutApp.CreateItem(0)
ogrencino = Cells(satir, "B").Value
ogrenciadi = Cells(satir, "C").Value
Set Alan = Range("A1:AB3,A" & satir & ":AB" & satir)
With OutMail
.To = mailadresi
.CC = ""
.BCC = ""
.Subject = "Öğrenci Notu Bilgilendirme"
.HTMLBody = "<br>Öğrenci Numarası : " & ogrencino & "<br>Öğrenci Adı : " & ogrenciadi & _
"<br>" & RangetoHTML(Alan) & .HTMLBody
'.SendUsingAccount = OutApp.Session.Accounts.Item(1)
.Display
.Send
End With
Set OutMail = Nothing
son:
Next j
Set OutApp = Nothing
End Sub
Sub mail_gonder_analiz()
Set shmail = Sheets("MailGönder")
mailsonsatir = shmail.Cells(Rows.Count, "B").End(3).Row
Sheets("ÖğrenciAnalizi").Select
sonsatir = Cells(Rows.Count, "B").End(3).Row
ogrenci = Cells(2, "B").Value
Set OutApp = CreateObject("Outlook.Application")
Set k = shmail.Range("C1:C" & mailsonsatir).Find(ogrenci, , xlValues, xlWhole)
satir = 0
mailadresi = ""
If k Is Nothing Then
Else
satir = k.Row
mailadresi = shmail.Cells(satir, "D").Value
End If
If mailadresi = "" Or InStr(mailadresi, "@") = 0 Then
MsgBox ("Mail adresi bulunamadı.")
GoTo son
End If
Set OutMail = OutApp.CreateItem(0)
ogrencino = Cells(satir, "B").Value
ogrenciadi = Cells(satir, "C").Value
Set Alan = Range("A1:O102")
With OutMail
.To = mailadresi
.CC = ""
.BCC = ""
.Subject = "Öğrenci Eksik Konu Analizi"
.HTMLBody = RangetoHTML(Alan) & .HTMLBody
'.SendUsingAccount = OutApp.Session.Accounts.Item(1)
.Display
.Send
End With
Set OutMail = Nothing
son:
Set OutApp = Nothing
End Sub
Function RangetoHTML(rng As Range)
' Changed by Ron de Bruin 28-Oct-2006
' Working in Office 2000-2013
Dim fso As Object
Dim ts As Object
Dim TempFile As String
Dim TempWB As Workbook
TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
'Copy the range and create a new workbook to past the data in
rng.Copy
Set TempWB = Workbooks.Add(1)
With TempWB.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).Select
Application.CutCopyMode = False
On Error Resume Next
.DrawingObjects.Visible = True
.DrawingObjects.Delete
On Error GoTo 0
End With
'Publish the sheet to a htm file
With TempWB.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=TempFile, _
Sheet:=TempWB.Sheets(1).Name, _
Source:=TempWB.Sheets(1).UsedRange.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
'Read all data from the htm file into RangetoHTML
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML = ts.readall
ts.Close
RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
"align=left x:publishsource=")
'Close TempWB
TempWB.Close savechanges:=False
'Delete the htm file we used in this function
Kill TempFile
Set ts = Nothing
Set fso = Nothing
Set TempWB = Nothing
End Function
Hocam nasıl eklicem yapamadım ben...
Hocam aşağıdaki hatayı veriyor mail 1 defa gönderdi,sonra hata veriyor...
Hocam dediğinizi yaptım mail gönderirken outlook izini soruyor her mail için izin istiyor,izin istemeden direk gönderebilirimiyim.Ayrıca outlook giden klasöründe takılı kalıyor.Ben outlook açınca mailleri gönderiyor.Bunları nasıl çözerim.
'.Send
.display
SendKeys "%G", True
Hocam yapamadım hata verdi...