-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathposlanie_emailu.vb
55 lines (43 loc) · 1.22 KB
/
poslanie_emailu.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
```VB
' Poslanie emailu z Excelu
Sub Send_email_fromexcel()
Dim edress As String
Dim subj As String
Dim message As String
Dim filename, fname2 As String
Dim outlookapp As Object
Dim outlookmailitem As Object
Dim myAttachments As Object
Dim path As String
Dim lastrow As Integer
Dim attachment As String
Dim x As Integer
x = 2
Set outlookapp = CreateObject("Outlook.Application")
Set outlookmailitem = outlookapp.createitem(0)
Set myAttachments = outlookmailitem.Attachments
path = "C:UsersUserDesktopstatements"
edress = Sheet1.Cells(x, 1)
subj = Sheet1.Cells(x, 2)
filename = Sheet1.Cells(x, 3)
fname2 = "photo.jpg"
attachment = path + filename
outlookmailitem.to = edress
outlookmailitem.cc = ""
outlookmailitem.bcc = ""
outlookmailitem.Subject = subj
outlookmailitem.Attachments.Add path & fname2, 1
outlookmailitem.htmlBody = "Thank you for your contract" _
& "nicely done this work" _
& ""
outlookmailitem.htmlBody = "" & outlookmailitem.htmlBody & ""
'outlookmailitem.body = "Please find your statement attached" & vbCrLf & "Best Regards"
outlookmailitem.display
'outlookmailitem.send
lastrow = lastrow + 1
edress = ""
x = x + 1
Set outlookapp = Nothing
Set outlookmailitem = Nothing
End Sub
``