Tools / References Microsoft Outlook XX Object Library eklenmeli
Tools / References Microsoft Word XX Object Library eklenmeli
'.Send satırı pasif durumda. İsterseniz tırnağı kaldırıp aktif edip direkt gönder yapılabilir.
- Kod: Tümünü seç
Private Sub UserForm_Initialize()
Dim sh1 As Worksheet
Dim lr As Long
Set sh1 = ThisWorkbook.Sheets("List")
lr = sh1.Range("A" & Rows.Count).End(xlUp).Row
With Me.ListBox1
.ColumnCount = 5
.ColumnHeads = True
.RowSource = "List!A2:E" & lr
End With
End Sub
- Kod: Tümünü seç
Private Sub CommandButton1_Click()
Dim sh2 As Worksheet, i As Integer
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim Alicilar As String
Dim doc As Word.Document
Set sh2 = ThisWorkbook.Sheets("Mail")
Alicilar = ""
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) = True Then
Alicilar = Alicilar & "; " & Me.ListBox1.Column(4, i)
End If
Next i
Alicilar = Mid(Alicilar, 3)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.Display
.BodyFormat = olFormatRichText
.To = Alicilar
'.cc = ""
'.bcc = ""
.Subject = sh2.Range("b1")
.HTMLBody = ""
'.Send
Set doc = .GetInspector.WordEditor
sh2.Range("b2:c7").Copy
doc.Range(0, 0).Paste
Application.CutCopyMode = False
End With
Set doc = Nothing
Set MailOutLook = Nothing
Set appOutLook = Nothing
End Sub
Bu iletideki ekleri görmek için gerekli yetkilere sahip değilsiniz.