PDA

View Full Version : the body of the vba generated mail is empty



inderdaad
10-26-2017, 02:45 AM
Hello,

in the code below I replaced .display with .Send
It generates a mail but the body stays empty

Selection.Copy
'Dim weekday As Integer
'weekday = Range("B3").Value
'If weekday = 3 Then
'Range("D3").Select
'Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
'Else: Range("D2").Select
'Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
'End If
Dim OutApp As Object
Dim OutMail As Object
Dim olInsp As Object
Dim oRng As Object

On Error Resume Next
Set OutApp = GetObject(, "Outlook.Application")
If Err <> 0 Then Set OutApp = CreateObject("Outlook.Application")
On Error GoTo 0

Set OutMail = OutApp.CreateItem(0)
With OutMail
.BodyFormat = 3
.To = Sheets("Lijst Bestellingen").Range("B4")
.CC = ""
.BCC = ""
.Subject = "Nieuwe bestelling"
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range
oRng.collapse 1
oRng.Paste
.Display
End With


Set OutMail = Nothing
Set OutApp = Nothing
Set olInsp = Nothing
Set wdDoc = Nothing
Set oRng = Nothing


Any ideas

Looking forward

snb
10-26-2017, 02:52 AM
Gebruik svp code tags !!

Do not use VBA copied code that you do not understand 100%

zie verder: http://www.snb-vba.eu/VBA_Outlook_external.html#L_4.1

Logit
10-26-2017, 07:30 AM
.
Insert this line under : .Subject



.Body = "This is your body"