[RAPOR] mail problemi
#7
ilginize çok teşekkürler, mail gönderme için aşağıdaki kodu kullanıyorum(tablodaki tanımlı birden fazla kullanıcıya göndermek için) bu kod yapısına göre xls ek olarak direkt gönderme işini nasıl çözebilirim. yardımlarınız için teşekkürler.
NOT : kodda HTMLBODY kısmına şimdilik sabit bir text yazdım, olması gereken "KURGONDER" isimli sorgu içeriği olacak.

Sub KURGONDER(Optional AttachmentPath)
On Error GoTo HATA
Dim MyDB As Database
Dim MyRS As Recordset
Dim MyRSto As Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("KURGONDER")
Set MyRSto = MyDB.OpenRecordset("KURGONDER_TO")
MyRSto.MoveFirst
Set objOutlook = CreateObject("Outlook.Application")
Do Until MyRSto.EOF
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add(MyRSto![EMAIL])
objOutlookRecip.Type = olTo
.SUBJECT = "Günlük Kur Bildirimi " & Now
.HTMLBODY = "Saat " & Time & " itibariyle kurlar aşağıdadır." _
& "<br />" _
& "<br /><strong>" & "PB : </strong>" & 1 _
& "<br /><strong>" & "KUR : </strong>" & 2 _
& "<br />"
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
Exit Sub
End If
Next
.Send
End With
MyRSto.MoveNext
Loop
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Exit Sub
HATA:
error_no = err.Number
End Sub



  Alıntı
Bu mesajı beğenenler:
#8
mevcut kodlarıma aşağıdaki sorguyu bir excele export etme kodunu ekledim ve attach ekleme kısmını aşağıdaki şekilde revize ettim.

bugun = Year(Date) & Month(Date) & Day(Date)
DoCmd.OutputTo acOutputQuery, "KURGONDER", acFormatXLS, "C:\hazine\archive\" & bugun & "_GUNLUKKUR.xls", False

...

If Not IsMissing(AttachmentPath) Then
EkPath = "C:\hazine\archive\" & bugun & "_GUNLUKKUR.xls"
Set objOutlookAttach = .Attachments.Add(EkPath)
End If



  Alıntı
Bu mesajı beğenenler:


Benzer Konular...
Konu: Yazar Cevaplar: Gösterim: Son Mesaj
  [VBA] Mail Ile Tablo Ya Da Sorgu Gönderme benuva 5 236 17-06-2023, 12:18
Son Mesaj: benuva
  [FORM] Liste Kutusundaki Veriyi Mail Ile Göndermek husem 8 909 27-01-2023, 00:52
Son Mesaj: BeyTor
  [FORM] Access Aktif Olan Formu, Mail Olarak Göndermek. Fenerli88 5 370 25-01-2023, 02:14
Son Mesaj: BeyTor
  [FORM] Mail gönderimi. orderyazbim 14 6.293 19-11-2022, 20:10
Son Mesaj: firatmalkoc
  Yoklama Defterinde Ay Ve Yıl Problemi omergenc7 16 635 22-09-2022, 13:54
Son Mesaj: omergenc7
  [VBA] Gmail Le Mail Gönderme Yeni Ayarları (çözüldü) hedefkaya 7 528 20-07-2022, 12:13
Son Mesaj: benuva
  [VBA] Hotmail Veya Yandex Ile Mail Gönderme (gmail Dışında Başka Hesapla) hedefkaya 0 219 28-06-2022, 14:49
Son Mesaj: hedefkaya
  [VBA] Ayrı Ayrı Outlook'la Mail Gönderebilmek benuva 9 552 21-06-2022, 01:18
Son Mesaj: dsezgin

Foruma Git:


Bu konuyu görüntüleyen kullanıcı(lar): 1 Ziyaretçi