Skip to main content

AccessTr.neT


formdaki bilgileri ilgili kişiye eposta olarak gönderme

formdaki bilgileri ilgili kişiye eposta olarak gönderme

Çözüldü #14
Size hem tek hem de toplu gönderim için bir örnek hazırladım.

Kodda smtp, e-mail adresiniz ve şifreniz kısımlarını sizin doldurmanız gerekiyor.
SMTP_Sunucu = "smtp.xxxx.xxx.tr"
Gonderenin_Mail_Adresi = "[email protected]"
Gonderenin_Mail_Sifresi = ""

Private Sub btn_EPOSTA_Click()
If IsNull(Me.eposta) Then
MsgBox "E-posta adresi yok!", vbCritical, "Hata oluştu."
Else
ePOSTA_Gonder
End If
End Sub

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 = "smtp.xxxx.xxx.tr"
Gonderenin_Mail_Adresi = "[email protected]"
Gonderenin_Mail_Sifresi = ""
Gonderilecek_Mail_Adresi = Me.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
'---------------------------------------------------------------
strBody = ""
strBody = strBody & " Sn. " & Me.adısoyadı
strBody = strBody & " Kesintiniz : " & Me.kesinti
strBody = strBody & " Maaş Tutarınız : " & Me.maas_tutar
'---------------------------------------------------------------
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Örnek E-Posta"
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

Biraz Html bilginiz varsa, strBody değişkenini Html kodları ile doldurarak,
mesaj içeriğini güzelleştirebilirsiniz.

Örneğin:
strBody = ""
strBody = strBody & "<p>"
strBody = strBody & "<font face='Verdana' size='2'>"
strBody = strBody & "Sn. " & Me.Yetkili.Column(1)
strBody = strBody & "<br><br>"
strBody = strBody & "Satınalma Yetkilisi olduğunuz " & Me.TALEP_EDENIN_ADI & " malzeme satınalma talebinde bulunmuştur."
strBody = strBody & "<br><br>"
strBody = strBody & "Concorde Menü'de 'MALZEME TALEPLERİ' programındaki 'Yetkili Onayı' formunda"
strBody = strBody & "<br>"
strBody = strBody & " malzeme talebine onay verebilir veya talebi iptal edebilirsiniz."
strBody = strBody & "<br><br><br>"
strBody = strBody & "Talep Edilen Malzemeler: (No:" & Me.TALEP_NO & ")"
strBody = strBody & "</font>"
strBody = strBody & "</p>"
strBody = strBody & "<table border='1' cellspacing='0' cellpadding='1' font face='Verdana' size='1' bgcolor='LightBlue'>"
strBody = strBody & "<tr>"
strBody = strBody & "<td><b>&nbsp;Malzeme&nbsp;</b></td>"
strBody = strBody & "<td><b>&nbsp;Miktar&nbsp;</b></td>"
strBody = strBody & "</tr>"
strBody = strBody & "<tr>"
If IsNull(RS.Fields("MLZ_OZELLIK")) Then
strBody = strBody & "<td>&nbsp;" & RS.Fields("MLZ_TANIMI") & "&nbsp;</td>"
Else
strBody = strBody & "<td>&nbsp;" & RS.Fields("MLZ_TANIMI") & "(" & RS.Fields("MLZ_OZELLIK") & ")&nbsp;</td>"
End If
strBody = strBody & "<td align=right>&nbsp;" & RS.Fields("MLZ_TALEP_MIKTARI") & " " & RS.Fields("MLZ_BIRIMI") & "&nbsp;</td>"
strBody = strBody & "</tr>"
strBody = strBody & "</table>"
strBody = strBody & "</font><br><br>"
.rar epostaah_seruz.rar (Dosya Boyutu: 20,76 KB | İndirme Sayısı: 158)
Bildiğini bilenin arkasından git, bildiğini bilmeyeni uyar, bilmediğini bilene öğret, bilmediğini bilmeyenden kaç.
Konfüçyüs
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
Cvp: formdaki bilgileri ilgili kişiye eposta olarak gönderme - Yazar: Seruz - 19/10/2010, 15:38
Task