Permalänk
Medlem

excel vba outlook attachment.add

Allting fungerar förutom .Attachment.Add = myFile , kommer inte riktigt framåt några tips?

Dim myFile As Variant Dim oMailItem As Object Dim oOLapp As Object myFile = Application.GetSaveAsFilename _ (InitialFileName:="aaa", _ FileFilter:="PDF Files (*.pdf), *.pdf") If myFile <> False Then ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=myFile, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False Set oOLapp = CreateObject("Outlook.application") Set oMailItem = oOLapp.CreateItem(0) With oMailItem .To = Range("D1") .CC = "" .Subject = Range("A2") .Body = "Mail and timereport generated by excel, see attachment for timereport!" .Display .Attachment.Add = myFile End With Set oOLapp = Nothing Set oMailItem = Nothing End If