+ Reply to Thread
Results 1 to 5 of 5

Can?t send long text from Excel via Outlook

Hybrid View

  1. #1
    Registered User
    Join Date
    12-12-2022
    Location
    Europe
    MS-Off Ver
    Excel? f?r Microsoft 365 MSO
    Posts
    3

    Question Can?t send long text from Excel via Outlook

    Hi all,
    I would like to send text from Excel via Outlook
    It is 189 words and 1243 symbols with a small picture.
    But I can not. I can send only a short text. This is my send string: =HYPERLINK("mailto:"&E38&"?subject=Test&body="&$B$53;"Senden")
    Maybe somebody can help me, please and explain what I should do to send 189 words with small pics
    Thanks in advance.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,438

    Re: Can?t send long text from Excel via Outlook

    This is one of many methods.

    The following allows you to edit this section of code, to specify what portion/s of the sheet range you want pasted into the email body:

    Sheets("Sheet1").Range("Q2:Y4") = Sheets("Sheet1").Range("B18:F20").Value
    Sheets("Sheet1").Range("Q7:V18") = Sheets("Sheet1").Range("B2:G13").Value

    Sheets("Sheet1").Range("B2:G13").Copy
    Sheets("Sheet1").Range("Q7:V18").PasteSpecial Paste:=xlPasteFormats


    ENTIRE CODE :


    Option Explicit
    
    
    Sub SendEmail()
        Dim rng As Range, OutApp As Object, OutMail As Object
        Dim sCC As String, sSubj As String, sEmAdd As String
        Dim objCombinedR As Range
         '// Change the values of these variables to suit
        sEmAdd = "abc@abc.com"
        sCC = ""
        sSubj = "My Subject"
         
        Set rng = Nothing
        On Error Resume Next
        
        Sheets("Sheet1").Range("Q2:Y4") = Sheets("Sheet1").Range("B18:F20").Value
        Sheets("Sheet1").Range("Q7:V18") = Sheets("Sheet1").Range("B2:G13").Value
        
        Sheets("Sheet1").Range("B2:G13").Copy
        Sheets("Sheet1").Range("Q7:V18").PasteSpecial Paste:=xlPasteFormats
        
        Set rng = Sheets("Sheet1").Range("Q2:V18")
        rng.AutoFit
        
        On Error GoTo 0
         
        With Application
            .EnableEvents = 0
            .ScreenUpdating = 0
            .Calculation = xlCalculationManual
        End With
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
         
        On Error Resume Next
        With OutMail
            .To = sEmAdd
            .CC = sCC
            .Subject = sSubj
            .HTMLBody = "<p>Dear Name:" & "<br><br>" & _
                    "Please see attached for your review.." & "<br><br>" & _
                    RangetoHTML(rng) & "<br><br>" & _
                    "Regards," & "<br><br>" & _
                    "Finance</p>"
            '.Send '// Change this to .Display if you want to view the email before sending.
            .Display
        End With
        On Error GoTo 0
         
        With Application
            .EnableEvents = 1
            .Calculation = xlCalculationAutomatic
        End With
        Sheets("Sheet1").Range("Q2:V18").Value = ""
        Set OutMail = Nothing: Set OutApp = Nothing
         
    End Sub
     
    Function RangetoHTML(rng As Range)
        Dim fso As Object, ts As Object, TempWB As Workbook, TempFile As String
         
        TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
         
        rng.Copy
        Set TempWB = Workbooks.Add(1)
        With TempWB.Sheets(1)
            .Cells(1).PasteSpecial Paste:=8
            .Cells(1).PasteSpecial xlPasteValues, , False, False
            .Cells(1).PasteSpecial xlPasteColumnWidths, , False, False
            .Cells(1).PasteSpecial xlPasteFormats, , False, False
            .Cells(1).Select
            Application.CutCopyMode = False
        End With
        With TempWB.PublishObjects.Add( _
            SourceType:=xlSourceRange, _
            Filename:=TempFile, _
            Sheet:=TempWB.Sheets(1).Name, _
            Source:=TempWB.Sheets(1).UsedRange.Address, _
            HtmlType:=xlHtmlStatic)
            .Publish (True)
        End With
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
        RangetoHTML = ts.readall
        ts.Close
        RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
        "align=left x:publishsource=")
         
        TempWB.Close 0
        Kill TempFile
         
        Set ts = Nothing: Set fso = Nothing: Set TempWB = Nothing
         
    End Function
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    12-12-2022
    Location
    Europe
    MS-Off Ver
    Excel? f?r Microsoft 365 MSO
    Posts
    3

    Re: Can?t send long text from Excel via Outlook

    Thanks a lot,
    I will have a look.
    For me it is Intrresting to know if it is possible to do this without programming?
    Why it does not send it at my case.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,438

    Re: Can?t send long text from Excel via Outlook

    If you want the email to auto send prior to reviewing .... change the following lines of code :

             
    "Finance</p>"
            '.Send '// Change this to .Display if you want to view the email before sending.
            .Display

    Comment out Display like this : '.Display

    Then Uncomment Send like this : .Send

  5. #5
    Registered User
    Join Date
    12-12-2022
    Location
    Europe
    MS-Off Ver
    Excel? f?r Microsoft 365 MSO
    Posts
    3

    Re: Can?t send long text from Excel via Outlook

    Thanks, a lot for your help. I think it is misunderstanding.
    I open an Excel file, and I press at send at the excel cell( =HYPERLINK("mailto:"&E38&"?subject=Test&body="&$B$53;"Senden") ) and the outlook will be opened.
    And after, I press at outlook send button.
    It means two applications: 1 Excel and after is 2Outlook.
    Maybe somebody knows what I have to correct to send longer text. Thanks
    Attachment 809167Attachment 809168

+ 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. Replies: 1
    Last Post: 10-20-2022, 10:44 AM
  2. Send data from outlook to excel
    By YOUSSEFam in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 02-03-2021, 05:03 PM
  3. [SOLVED] VBA code to send Outlook email with HTML text no longer working
    By Twaddy006 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-04-2016, 01:53 PM
  4. VBA to Send Email From Excel Using Outlook
    By jar002 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-24-2014, 10:08 AM
  5. Using Excel vba to send hyperLinks in the body text of an Outlook email using a checkbox
    By PatrickASnyder in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2013, 04:13 PM
  6. Send Plain Text Email in Outlook
    By Trav01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2012, 12:59 AM
  7. Send a fax from within excel via outlook!
    By NSKearns in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-15-2006, 10:20 AM

Tags for this Thread

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