Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29935

Sending Outlook email from MS Access form

$
0
0

I want to draft an Outlook email from my Access form and have it display so I can edit and send from Outlook.

The code below works:

Private Sub Command210_Click()
Dim OlApp As Object
Dim olMailItem As Object

    Set OlApp = CreateObject("Outlook.Application")
    Set olMailItem = OlApp.CreateItem(0)

    With olMailItem
      .Subject = Me.CPN & ""& Me.WBPN
      .Body = "this is a test"
      .Display
   End With

End Sub

But I get a run time error when I try to use text from a form textbox (named WBEmailFU) for the body of the email.

Private Sub Command210_Click()
Dim OlApp As Object
Dim olMailItem As Object

    Set OlApp = CreateObject("Outlook.Application")
    Set olMailItem = OlApp.CreateItem(0)

    With olMailItem
      .Subject = Me.CPN & ""& Me.WBPN
      .Body = Me.WBEmailFU
      .Display
   End With

End Sub

I get a

run time error "Method 'Body' of object'_MailtItem' failed

The text box WBEmailFU is formatted as LongText. Why does it work when I define .body= "a text string" but not when .body is defined as a text field from my form?


Viewing all articles
Browse latest Browse all 29935

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>