
Sub Invioemail()
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim Subj As String
Dim BodyText As String
EmailAddr = Range("i2").Value '<<< inserire indirizzi
Subj = "nota n° " & Range("j4") & " del " & Range("j6").Value
BodyText = "In allegato ."
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = EmailAddr
.CC = ""
.BCC = ""
.Subject = Subj
.Body = BodyText
.Attachments.Add ActiveWorkbook.FullName 'inserisce il file excel in allegato
.Display 'or use .send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub |
'Recupera il contenuto delle due celle A1 e A10 e lo mette in some_text con un ritorno a capo
'poi assegna al corpo dell'email questo testo
for each v in [A1,A10]
some_text = v & vbCrLf
next
OutMail.Body = some_text |
With Sheets("Foglio1")
ur = .Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range(.Cells(1, 1), .Cells(ur, 5))
With OutMail
For Each v In rng
some_text = some_text & v & vbCrLf
Next |
For Each v In rng
some_text = some_text & v & " " '<-- c'è uno spazio vuoto tra le virgolette!
if v.Column = 5 then some_text = some_text & vbCrLf '<-- dopo la quinta colonna andiamo a capo
Next
|
For Each v In rng
some_text = some_text & v & IIf(v.Column = 5, vbCrLf, " ")
Next |
Sub esportapdf()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:Nota Accredito.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End Sub
NELLA MACRO MAIL
.Attachments.Add "C:Nota Accredito.pdf"
|
