+ Reply to Thread
Results 1 to 6 of 6

attach contents of textbox in userform as body of email vba

  1. #1
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    attach contents of textbox in userform as body of email vba

    Hi all,
    I have seen many threads on line, but could not get a definative solution.
    Following code will activate outlook.
    I am trying following:
    To.... address will be fetched from textbox29
    Main body text will be fetched from textbox14

    Very challanging.
    So far so good this is what I have done.
    Please help
    Kind regards

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Try removing Sheets("Sheet1") and Worksheets("Sheet1").
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: attach contents of textbox in userform as body of email vba

    Try This

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: attach contents of textbox in userform as body of email vba

    Hi Norie & Yeshagarwal,
    Thanks for your suggestions.
    The combunations iof both suggestions have worked well.
    Well done to everyone.
    Norie's suggestion of removing worksheets("Sheet1") and removing userform2 has done a trick.
    Final code is as follows which works well.


    Private Sub commandbutton4_click()
    Please Login or Register  to view this content.
    Thanks
    Kind regards

  5. #5
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: attach contents of textbox in userform as body of email vba

    Hi again,
    Last question before I close this thread as solved.

    How do I add more input from more text boxes
    Please Login or Register  to view this content.
    Thanks again
    Kind regards

  6. #6
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: attach contents of textbox in userform as body of email vba

    Dim aOutlook As Object
    Dim aEmail As Object
    Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String

    Set aOutlook = CreateObject("Outlook.Application")
    Set aEmail = aOutlook.CreateItem(0)

    'set Importance
    aEmail.Importance = 2
    'Set Subject
    aEmail.Subject = "Trying Hard"
    'Set Body for mail
    aEmail.Body = TextBox14.Text & vbnewline & "your text" & vbnewline & textbox7.text
    'I want to add a line below text from textbox6, 7, 8, 9, 10.
    'and last line From " Me" something like that
    'Set Recipient
    aEmail.To = TextBox31.Text

    'Send Mail
    aEmail.Display

    End Sub

  7. #7
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: attach contents of textbox in userform as body of email vba

    Wonderful Sir,
    Great. It works well.
    Thanks again for your kind help
    Best regards

  8. #8
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: attach contents of textbox in userform as body of email vba

    Wonderful Sir,
    Great. It works well.
    Thanks again for your kind help
    Best regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need to attach Image from special folders(multiple platforms), into body of email
    By kingkyle2005 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-19-2013, 11:26 AM
  2. Help - Attach an image from the userform into the body of an email in lotus notes
    By dragontm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2013, 05:35 AM
  3. Creating code to publish pdf and attach via xl2010 and insert object in body of same email
    By ChrisBrennan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2013, 09:08 PM
  4. possible to write email body in userform's textbox?
    By dan2010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2010, 05:12 AM
  5. Copy a sheet to the body of an email or attach part of a spreadsheet
    By David in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2005, 10:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1