Goedemorgen,
Ik heb een vraag aan jullie.
Probeer al een tijd om een PDF bestand als bijlage te versturen in outlook (1 sheet)
Het lukt me niet en ook op de site van Ron de Bruin kom ik niet wijzer uit.
Dit is de code die ik nu heb en werkt gewoon goed. Alleen is het het gehele excel bestand. dus ook de sheets plus data etc.
Sub send_mail()
'
' Macro5 Marco
'
Application.DisplayAlerts = False
Dim Country As Integer, result As String
Country = Range("I1").Value
x = Range("c12")
y = Range("c11")
Dim Lo As ListObject
Dim r As Range
Dim oApp As New Outlook.Application
Dim oMail As Outlook.MailItem
With CreateObject("Outlook.Application").CreateItem(0)
'The Netherlands.
If Country = 1 Then
.To = "email adres"
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In de bijlage een filiaalmelding. Vragen over deze melding kun je contact op nemen met DC-A Site Security. Met vriendelijke groet"
.Attachments.Add ThisWorkbook.FullName
.Display
.Send
MsgBox ("E-mail is verstuurd")
End If
'Belgium.
If Country = 2 Then
.To = "email adres ; email adres "
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security. Met vriendelijke groet"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'Germany.
If Country = 3 Then
.To = "email adres ; email adres"
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security. Mit freundlichen Grüßen"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'France.
If Country = 4 Then
.To = "email adres ; email adres"
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security. "
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'Luxembourgh.
If Country = 5 Then
.To = "email adres"
.CC = "email adres; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'Austria.
If Country = 7 Then
.To = "email adres ; email adres"
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'Poland.
If Country = 8 Then
.To = "Email adres"
.CC = "Email adres; Email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
End With
'
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Alvast bedankt!
Gr,
Maurice
Ik heb een vraag aan jullie.
Probeer al een tijd om een PDF bestand als bijlage te versturen in outlook (1 sheet)
Het lukt me niet en ook op de site van Ron de Bruin kom ik niet wijzer uit.
Dit is de code die ik nu heb en werkt gewoon goed. Alleen is het het gehele excel bestand. dus ook de sheets plus data etc.
Sub send_mail()
'
' Macro5 Marco
'
Application.DisplayAlerts = False
Dim Country As Integer, result As String
Country = Range("I1").Value
x = Range("c12")
y = Range("c11")
Dim Lo As ListObject
Dim r As Range
Dim oApp As New Outlook.Application
Dim oMail As Outlook.MailItem
With CreateObject("Outlook.Application").CreateItem(0)
'The Netherlands.
If Country = 1 Then
.To = "email adres"
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In de bijlage een filiaalmelding. Vragen over deze melding kun je contact op nemen met DC-A Site Security. Met vriendelijke groet"
.Attachments.Add ThisWorkbook.FullName
.Display
.Send
MsgBox ("E-mail is verstuurd")
End If
'Belgium.
If Country = 2 Then
.To = "email adres ; email adres "
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security. Met vriendelijke groet"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'Germany.
If Country = 3 Then
.To = "email adres ; email adres"
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security. Mit freundlichen Grüßen"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'France.
If Country = 4 Then
.To = "email adres ; email adres"
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security. "
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'Luxembourgh.
If Country = 5 Then
.To = "email adres"
.CC = "email adres; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'Austria.
If Country = 7 Then
.To = "email adres ; email adres"
.CC = "email adres ; email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
'Poland.
If Country = 8 Then
.To = "Email adres"
.CC = "Email adres; Email adres"
.Subject = y & " " & x
.Body = "In the appendix the new store notification. Any questions about this info, You can contact site security"
.Attachments.Add ThisWorkbook.FullName
.Send
MsgBox ("E-mail is verstuurd")
End If
End With
'
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Alvast bedankt!
Gr,
Maurice