简体   繁体   中英

VBA Send Mail with TextBox from userform as body content on Windows 10

I've been using the code below without any problems for a while now. I have a Powerpoint slide, that when clicked opens a UserForm. That userform contains a button, named SendMail, and a TextBox.

the user insert comments into the Textbox, clicks SendMail and I get his comments in my e-mail box. This code doesn't seem to work properly, when a Windows10 user hits SendMail. I get an e-mail with a subject but the body is empty.

See below the code that works for any other Windows (Please note EmailBox is the name for the TextBox where the user inputs his questions):

Private Sub SendEmail1_Click()

Dim OutApp As Object
Dim OutMail As Object
Dim strText As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .Body = EmailBox
        .To = "random.email@yahey.com"
        .CC = ""
        .BCC = ""
        .Subject = "Question about random stuff"
        .Send
    End With

    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

    Unload Me
End Sub

Anyone has any ideas??

As per Nathan_Sav comment, added .value to the body line and it worked perfectly.

.Body = EmailBox.value

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM