• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Send eMail with Snapshot from Excel

RDaga

Member
Hi Friends, I have tried searching a lot but was unable to find a complete functioning VBA hence thought of reaching out for help. I am trying to create a quality audit form and once the audit is completed if the auditor clicks on the email icon on the top left it should send an email to the email address in cell D3 and cc the email address in D5 and the email body will contain the snapshot of the form.

1715345998755.png
 

Attachments

  • Audit Form.xlsm
    39.8 KB · Views: 4
is it possible that in the body we can take the cell reference of the name and start the email addressing the person?
 
hi

check this file..

>>> use code - tags <<<
Code:
Sub Create_Email()

'Copy the desired range as a picture
    Dim ws As Worksheet, rg As Range
    Set ws = ThisWorkbook.Sheets("Audit Sheet")
    Set rg = ws.Range("B2:L19")
    rg.CopyPicture Appearance:=xlScreen, Format:=xlBitmap

'Set the date string to be used in the email
    Dim strDate As String
    strDate = Range("J2")
    strname = Range("D2")
   
'Create a new Outlook email
    Dim olApp As Object, olMail As Object
    Set olApp = CreateObject("Outlook.Application")
    Set olMail = olApp.CreateItem(0) 'olMailItem
    With olMail
        .SentOnBehalfOfName = ""
        .To = Range("D3")
        .CC = Range("D5")
        .BCC = ""
        .Subject = "Audit Report (" & strDate & ")"
        .Display

    ' paste the picture into the body, followed by a basic signature
        Dim wordDoc As Variant
        Set wordDoc = .GetInspector.WordEditor
        With wordDoc.Range
            .PasteSpecial DataType:=4 'wdPasteBitmap
        With wordDoc.InlineShapes(1)
            .ScaleHeight = 120
         End With
            .InsertParagraphAfter
            .InsertParagraphAfter
            .InsertAfter "Thank you,"
            .InsertParagraphAfter
            .InsertAfter "John Smith"
        End With
      

    ' apply formatting and insert greeting before the picture
        .HTMLBody = "<BODY style = font-size:11pt; font-family:Calibri;>" & _
            "<p><b>Good Day Mr/Ms " & strname & "</b></p>" & _
            "<p>Please find below Audit Report. </p>" & .HTMLBody
            

    End With

you can change as your wish.
 

Attachments

  • 1 Audit Form.xlsm
    50.1 KB · Views: 0
Last edited by a moderator:
you are a life saver @mohamed ilyas, just a final piece where I am stuck :(
I tried to change the code so that instead of displaying the email it directly sends it but by using .Send instead of .Display but I am getting the below error message. Also the email that goes is a blank email with no image.

1715790958440.png
 
Hi

check this file.. there is two option. if you want send without display, use the option and run.. if you want check display.. choos the option and run.
 

Attachments

  • 1 Audit Form.xlsm
    52.4 KB · Views: 2
Back
Top