ekli dosya mail gönderme

Katılım
27 Şubat 2008
Mesajlar
307
Excel Vers. ve Dili
Office 2016
aşağıdaki gibi bir kodum var ama yanlış giden şu; dosya eklerken her zaman dosya adı değişiyor. Bende dosya adını isim koduyla belirttim. Fakat ekleme kısmında nasıl yapacağımı bilemedim

Private Sub CommandButton2_Click()

sor = MsgBox("e posta Göndermek İstiyor Musunuz ?", vbYesNo)
If sor = vbNo Then Exit Sub

kullanici_sahibi = ""
kullanici_parola = ""

Set objEmail = CreateObject("CDO.Message")

objEmail.From = kullanici_sahibi
objEmail.To = "" 'Gönderilecek e-mail adresi

isim = Sheets("VAKA CETVELİ (VAR İSE)").[aa1] & " " & "KIZAMIK VAKA FORMU"

objEmail.Subject = "KIZAMIK VAKA FORMU"
objEmail.TextBody = "KIZAMIK VAKA FORMU"
objEmail.AddAttachment "Masaüstü\isim.pdf"

With objEmail.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = kullanici_sahibi
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = kullanici_parola
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "eposta.saglik.gov.tr"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Update

End With
objEmail.Send
MsgBox "'den DOSYA MAİL OLARAK GÖNDERİLMİŞTİR"
End Sub
 
Katılım
24 Nisan 2005
Mesajlar
3,685
Excel Vers. ve Dili
Office 2016 EN 64 Bit
Altın Üyelik Bitiş Tarihi
25/05/2022
Aşağıdaki şekilde deneyiniz.
Masaüstünde aynı dosya adında pdf dosyası var olduğunu sayıyorum.

Kod:
yol = Environ("USERPROFILE") & "\Desktop\" & isim & ".pdf"
objEmail.AddAttachment yol
 
Üst