(03/01/2016, 17:59)ozanakkaya yazdı: Özgür'ün dediği gibi, programlama dillerinde bazı kodlar ortak. Ancak bu kodda epostanın HTMLBody alanına veri aktarıldığı için Html kodlaması istiyor.
Ben deneme yapmadığımdan alt satıra geçmesi için "& Chr(13) & Chr(10)" kodu ekledim. Ancak bu kod HTMLBody alanında işlemiyor.
BodyYenile kodunun aşağıdaki gibi Html tagları ile düzenlenirse tablo halinde mail gönderir.
Sub BodyYenile()
mtn_body = ""
mtn_body = " Sn. " & Me.g_kimlik & "<br />"
Me.fiyat_dalt.SetFocus
DoCmd.GoToRecord , , acFirst
mtn_body = mtn_body & "<table><tbody><tr><td style='width:100px;'>Kalite:</td><td style='width:100px;'>En:</td><td style='width:100px;'>Metraj:</td></tr><tr>"
For a = 0 To Trim(Forms!fiyatsorgu!fiyat_dalt.Form.RecordsetClone.RecordCount) - 1
mtn_body = mtn_body & "<td>" & [fiyat_dalt].Form![d_kalite] & "</td>"
mtn_body = mtn_body & "<td>" & [fiyat_dalt].Form![d_metraj] & "</td>"
mtn_body = mtn_body & "<td>" & [fiyat_dalt].Form![d_en] & "</td>"
mtn_body = mtn_body & "<tr></tr>"
Me.fiyat_dalt.SetFocus
DoCmd.GoToRecord , , acNext
Next a
mtn_body = mtn_body & "</tr></tbody></table>"
mtn_body = mtn_body
Me.g_musteri.SetFocus
End Sub
Kod:
Private Sub ePOSTA_Gonder()
On Error GoTo Hata
'---------------------------------------------------------------
Const cdoAnonymous = 0
Const cdoBasic = 1
Const cdoNTLM = 2
Dim objMessage As Object
Dim SMTP_Sunucu, Gonderenin_Mail_Adresi, Gonderenin_Mail_Sifresi, Gonderilecek_Mail_Adresi, strBody
'---------------------------------------------------------------
SMTP_Sunucu = "********"
Gonderenin_Mail_Adresi = "******"
Gonderenin_Mail_Sifresi = "*******"
Gonderilecek_Mail_Adresi = Me.g_eposta
If Gonderenin_Mail_Adresi = "" Or Gonderenin_Mail_Sifresi = "" Or Gonderilecek_Mail_Adresi = "" Then
MsgBox "Bilgileriniz eksik olduğu için e-posta gönderilemiyor !", vbCritical, "Hata oluştu."
Exit Sub
End If
'---------------------------------------------------------------
mtn_body = ""
mtn_body = " Sn. " & Me.g_kimlik & "<br />"
Me.fiyat_dalt.SetFocus
DoCmd.GoToRecord , , acFirst
mtn_body = mtn_body & "<table><tbody><tr><td style='width:100px;'>Kalite:</td><td style='width:100px;'>En:</td><td style='width:100px;'>Metraj:</td></tr><tr>"
For a = 0 To Trim(Forms!fiyatsorgu!fiyat_dalt.Form.RecordsetClone.RecordCount) - 1
mtn_body = mtn_body & "<td>" & [fiyat_dalt].Form![d_kalite] & "</td>"
mtn_body = mtn_body & "<td>" & [fiyat_dalt].Form![d_metraj] & "</td>"
mtn_body = mtn_body & "<td>" & [fiyat_dalt].Form![d_en] & "</td>"
mtn_body = mtn_body & "<tr></tr>"
Me.fiyat_dalt.SetFocus
DoCmd.GoToRecord , , acNext
Next a
mtn_body = mtn_body & "</tr></tbody></table>"
mtn_body = mtn_body
Me.g_musteri.SetFocus
'---------------------------------------------------------------
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Fiyat Talebi"
objMessage.From = Gonderenin_Mail_Adresi
objMessage.To = Gonderilecek_Mail_Adresi
objMessage.HTMLBody = strBody
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Gonderenin_Mail_Adresi
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Gonderenin_Mail_Sifresi
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTP_Sunucu
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
objMessage.Send
MsgBox "İlgili kişiye e-posta gönderilmiştir.", vbInformation, "İşlem tamam"
Exit Sub
'---------------------------------------------------------------
Hata:
MsgBox "E-posta gönderimi başarısız oldu!", vbCritical, "Hata oluştu."
End Sub