Results 1 to 9 of 9

Copy attachment contents into body of email !

Threaded View

  1. #1
    Registered User
    Join Date
    01-22-2015
    Location
    England
    MS-Off Ver
    Microsoft Office 365
    Posts
    92

    Copy attachment contents into body of email !

    Hi all.

    I have the following code that is being used to send an attachment via email.

    IS there something I can add to the code that will allow the contents of a sheet to be copied and pasted into the body of the email.

    Any help would be much appreciated

    
    Option Explicit
    
    
    Sub Button1_Click()
    
        Dim lErrorNo    As Long
        Dim OutMail     As Object
        Dim myEmail     As String
        Dim OutApp      As Object
        Dim xNmae       As Object
    
        If ThisWorkbook.Saved = True Then
    
              Set OutApp = CreateObject("Outlook.Application")
              Set OutMail = OutApp.CreateItem(0)
              Set xNmae = OutApp.GetNamespace("MAPI")
    
              myEmail = xNmae.Session.CurrentUser.AddressEntry. _
                              GetExchangeUser.PrimarySmtpAddress
    
              With OutMail
    
                  .To = "XXXX;XXXXX"
                  .CC = myEmail
                  .BCC = ""
                  .Subject = "Ad Hoc Report Request"
                  .Body = "Hi. Please find attached my ad hoc request form."
                  .Attachments.Add ActiveWorkbook.FullName
    
                  On Error Resume Next
                      .Send
    '                 Record the number of any error which may have occurred
                      lErrorNo = Err.Number
                  On Error GoTo 0
    
    '             Display a "Success" or "Failure" message as appropriate
                  If lErrorNo = 0 Then
                        MsgBox "Your request has succesfully been sent by email.You may now close the workbook", vbInformation
                  Else: MsgBox "An error occurred - the email was NOT sent", vbCritical
                  End If
    
              End With
    
        Else: MsgBox "Please save the workbook first..", vbInformation
    
        End If
    
        Set OutMail = Nothing
        Set OutApp = Nothing
        Set xNmae = Nothing
    
    End Sub
    Last edited by V.Cell; 06-29-2016 at 05:40 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy email contents to new email whilst saving attachment.
    By X82 in forum Outlook Programming / VBA / Macros
    Replies: 25
    Last Post: 08-18-2015, 03:16 PM
  2. Email each person in excel, including a body of text and attachment
    By memanja in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-12-2014, 10:41 AM
  3. Emailing PDF, another attachment, and with range in email body
    By supcussy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2012, 10:03 PM
  4. [SOLVED] email excel spreadsheet as body of message, not as attachment
    By Email Spreadsheet as Body of Email Msg. in forum Excel General
    Replies: 6
    Last Post: 06-18-2012, 01:01 PM
  5. Modifying VB Code/Macro to put selection into body of email instead of attachment.
    By excelstacy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2011, 05:34 PM
  6. Automatic email of excel contents as email body
    By naveenn08 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2009, 08:26 AM
  7. Email excel as body rather than attachment
    By jhahes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2006, 04:30 PM

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