Send mail fra Excel
Hej,Har fundet dette script som skal kunne åbne outlook og sende bestemt tekst.
Jeg får en error 424.
Nogen der kan se hvad der er galt ?
Sub esendtable()
Dim outlook As Object
Dim newEmail As Object
Dim xInspect As Object
Dim pageEditor As Object
Set outlook = CreateObject("Outlook.Application")
Set newEmail = outlook.CreateItem(0)
With newEmail
.To = Sheet1.Range("A2").Text
.CC = ""
.BCC = ""
.Subject = "Data"
.Body = "Please find the requested information" & vbCrLf & "Best Regards"
.display
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor
Sheet1.Range("B2:E5").Copy
pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)
.display
.Send
Set pageEditor = Nothing
Set xInspect = Nothing
End With
Set newEmail = Nothing
Set outlook = Nothing
End Sub