Sub Invia_email1()
Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range
destinatario = Worksheets("V1").Cells(14, 3).Value
allegato = Worksheets("V1").Cells(15, 12).Value
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sendrng = Worksheets("V1").Range("A1:K57")
Set AWorksheet = ActiveSheet
With Sendrng
.Parent.Select
Set rng = ActiveCell
.Select
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
With .Item
.To = destinatario
.CC = ""
.BCC = ""
.Subject = "VOUCHER"
If allegato <> "" Then .Attachments.Add allegato
.Send
End With
End With
rng.Select
End With
AWorksheet.Select
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
Sheets("VOUCHER").Select
End Sub
Sub Invia_email2()
Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
destinatario = Worksheets("V2").Cells(14, 3).Value
allegato = Worksheets("V2").Cells(15, 12).Value
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sendrng = Worksheets("V2").Range("A1:K57")
Set AWorksheet = ActiveSheet
With Sendrng
.Parent.Select
Set rng = ActiveCell
.Select
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
With .Item
.To = destinatario
.CC = ""
.BCC = ""
.Subject = "VOUCHER"
If allegato <> "" Then .Attachments.Add allegato
.Send
End With
End With
rng.Select
End With
AWorksheet.Select
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
Sheets("VOUCHER").Select
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
|