• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Userformdan mail gönderirken EK bölümü zorunluluğunun kaldırılması

Katılım
5 Şubat 2016
Mesajlar
274
Excel Vers. ve Dili
Office 365 Türkçe
Aşağıda bulunan kodda mail gönderebilen bir userform yaptım. Gözat butonu vasıtası ile dosya yolu seçip texrtbox4 e yazdırıyorum. Kodda göreceğiniz üzere textbox4 te yazan dosya yolundaki eki mail ile gönder komutu var. Fakat eksiz mail göndermek istediğim de ek seçmeyi zorunlu tutup hata veriyor. Eğer textbox4 boşsa ek göndermeyi pas geç demek için ne gibi bir güncelleme yapmam lazım ? Şimdiden yardımlarınız için teşekkür ederim.

Kod:
Private Sub CommandButton1_Click()
Dim OutlookApp As Object
Dim MItem As Object
Dim cell As Range
Dim email_ As String
Dim subject_ As String
Dim body_ As String
Dim attach_ As String

Set OutlookApp = CreateObject("Outlook.Application")

email_ = UserForm8.TextBox1.Value
subject_ = UserForm8.TextBox2.Value
body_ = UserForm8.TextBox3.Value
bodyS_ = UserForm8.TextBox4.Value

'create Mail Item and send it
Set MItem = OutlookApp.CreateItem(0)
 
Application.DisplayAlerts = False
With MItem
.To = email_
.Subject = subject_
.Body = body_
.Attachments.Add bodyS_
.Send
End With
Application.DisplayAlerts = True
Me.TextBox1 = Empty
Me.TextBox2 = Empty
Me.TextBox3 = Empty
Me.TextBox4 = Empty
Me.ComboBox1 = Empty
MsgBox "Mail başarıyla gönderildi."
UserForm8.HIDE
End Sub
 
Hocam çok teşekkür ederim. Emeğinize sağlık.
 
Rica ederim. Kolay gelsin.
 
Aşağıda bulunan kodda mail gönderebilen bir userform yaptım. Gözat butonu vasıtası ile dosya yolu seçip texrtbox4 e yazdırıyorum. Kodda göreceğiniz üzere textbox4 te yazan dosya yolundaki eki mail ile gönder komutu var. Fakat eksiz mail göndermek istediğim de ek seçmeyi zorunlu tutup hata veriyor. Eğer textbox4 boşsa ek göndermeyi pas geç demek için ne gibi bir güncelleme yapmam lazım ? Şimdiden yardımlarınız için teşekkür ederim.

Kod:
Private Sub CommandButton1_Click()
Dim OutlookApp As Object
Dim MItem As Object
Dim cell As Range
Dim email_ As String
Dim subject_ As String
Dim body_ As String
Dim attach_ As String

Set OutlookApp = CreateObject("Outlook.Application")

email_ = UserForm8.TextBox1.Value
subject_ = UserForm8.TextBox2.Value
body_ = UserForm8.TextBox3.Value
bodyS_ = UserForm8.TextBox4.Value

'create Mail Item and send it
Set MItem = OutlookApp.CreateItem(0)

Application.DisplayAlerts = False
With MItem
.To = email_
.Subject = subject_
.Body = body_
.Attachments.Add bodyS_
.Send
End With
Application.DisplayAlerts = True
Me.TextBox1 = Empty
Me.TextBox2 = Empty
Me.TextBox3 = Empty
Me.TextBox4 = Empty
Me.ComboBox1 = Empty
MsgBox "Mail başarıyla gönderildi."
UserForm8.HIDE
End Sub




Merhaba kodunuzu inceledim ama kendime uyarla yamadım maalesef. Kendi özel bilgilerinizi silip excel halinde eklemeniz mümkün müdür acaba. Uzun zamandır aradığım bir husustu. Emeğinizi paylaşmama konusunda hassas olabilirsiniz saygı duyarım.
 
Öncelikle merhaba. Tabii ki paylaşırım, bilgi paylaştıkça çoğalır. Mezara götürmeyeceğiz en nihayetinde.
Kodlarda 'ile işaretlediğim yerleri kaldırıp kendi bilgilerini yazarsan orası en üstteki comboboxa varsayılan mail listesini yüklüyor , elle yazmana gerek kalmaz. Şurası yani


Kod:
'Private Sub UserForm_initialize()
'Me.TextBox1 = Empty
'With Sheets("ŞİRKET")
'For Each Veri In .Range("J2:J500")
'If Veri.Value <> "" Then
'ComboBox1.AddItem Veri.Value
'End If
'Next
'End With
'ComboBox1.ListIndex = 0
'ComboBox1.Text = ComboBox1.List(0)
'ComboBox1 = Empty
'End Sub

Aşağıda linki verdim.

http://dosya.co/wa4sj8wdo1kn/MAIL_SYSTEM.xlsm.html
 
Geri
Üst