Sub vice_priloh_Click()
Dim myItem As Outlook.MailItem
Dim strFolderPath As String
Dim strFileName As String
Dim bIsCreated As Boolean
On Error Resume Next
Set myItem = Application.ActiveInspector.CurrentItem
On Error GoTo 0
If myItem Is Nothing Then
Set myItem = Application.CreateItem(olMailItem)
bIsCreated = True
ElseIf myItem.Class <> olMail Then
Set myItem = Application.CreateItem(olMailItem)
bIsCreated = True
End If
With myItem
strFolderPath = "C:\a pracovni\adresare\adam\"
strFileName = Dir(strFolderPath, vbNormal)
While Len(strFileName) > 0
.Attachments.Add (strFolderPath & strFileName)
strFileName = Dir
Wend
If bIsCreated Then .Display
.HTMLBody = "posíláme protokoly" & " " & " Najděte přiložený soubor " & .HTMLBody
.To = "ab@volny.cz"
.CC = "ab@volny.cz"
.BCC = "ab@volny.cz"
.Subject = "TEST MAIL"
'.Send
End With
Set myItem = Nothing
End Sub
Excel:
Private Sub vice_priloh_Click()
' Reference Microsoft Outlook xx.x Object Library
Dim objOutlook As Object
Dim myItem As Object
Dim strFolderPath As String
Dim strFileName As String
Dim bIsCreated As Boolean
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0
If objOutlook Is Nothing Then
Set objOutlook = CreateObject("Outlook.Application")
bIsCreated = True
End If
Set myItem = objOutlook.CreateItem(0)
With myItem
strFolderPath = "C:\a pracovni\adresare\adam\"
strFileName = Dir(strFolderPath, vbNormal)
While Len(strFileName) > 0
.Attachments.Add (strFolderPath & strFileName)
strFileName = Dir
Wend
.HTMLBody = "posíláme protokoly" & " " & " Najděte přiložený soubor " & .HTMLBody
.To = "ab@volny.cz"
.CC = "ab@volny.cz"
.BCC = "ab@volny.cz"
.Subject = "TEST MAIL"
.Display
'.Send
End With
If bIsCreated Then objOutlook.Quit
Set myItem = Nothing
Set objOutlook = Nothing
End Sub
A odkiaľ sa majú brať tie údaje na doplnenie ?citovat