Consulting

Results 1 to 3 of 3

Thread: the body of the vba generated mail is empty

  1. #1

    the body of the vba generated mail is empty

    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

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    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

  3. #3
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    Insert this line under : .Subject

    .Body = "This is your body"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •