Screen shot to email via button click

ukphoenix

New Member
Joined
Jul 25, 2020
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hi guys and Girls.

Im on the final stages of the sheet im creating but cant figure the email bit out. The first version I had only emailed the image to the first email address, everyone else got a blank mail. So ive now found another macro that creates the pci but cant get it to work. Its sending the mail so that parts Anyone help pls?



VBA Code:
Sub createJpg(Namesheet As String, nameRange As String, nameFile As String)

    ThisWorkbook.Activate

    Worksheets(Namesheet).Activate

    Set Plage = Workbooks("WS TemplateV2.xlsm").Worksheets("3.Shipment details").Range("A2:J50")

    Plage.CopyPicture

        With ThisWorkbook.Worksheets(Namesheet).ChartObjects.Add(Plage.Left, Plage.Top, Plage.Width, Plage.Height)

        .Activate

        .Chart.Paste

        .Chart.Export Environ$("temp") & "\" & nameFile & ".jpg", "JPG"

    End With

    Worksheets(Namesheet).ChartObjects(Worksheets(Namesheet).ChartObjects.Count).Delete

Set Plage = Nothing

End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I think its something to do with the string requesting. below is the full email macro

VBA Code:
Sub Mail_Save()

    ' SaveSend Macro

    Application.DisplayAlerts = False
    Application.ScreenUpdating = False

    Dim OutApp As Object
    Dim OutMail As Object

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

    On Error Resume Next

    With OutMail

        .To = "" 'emai here
        .CC = ""
        .BCC = ""

        .Subject = "Loads to West"

        'first we create the image as a JPG file

        Call createJpg("Loads to West", "A2:J30", "WestFile")

        'we attached the embedded image with a Position at 0 (makes the attachment hidden)

        TempFilePath = Environ$("temp") & "\"

        .Attachments.Add TempFilePath & "WestFile.jpg", olByValue, 0

              
        'Then we add an html <img src=''> link to this image
        'Note than you can customize width and height - not mandatory
                

        .HTMLBody = "<body>Hi All, <br><br> Kindly find the report below of loads to  move to west site:<br><br>" & _
        "<img src='cid:WestFile.jpg'" & "width='1300' height='1200'><br>"

        .Display
        .Send

    End With

    On Error GoTo 0

    With Application

        .EnableEvents = True
        .ScreenUpdating = True

    End With
 
    Set OutMail = Nothing
    Set OutApp = Nothing

    ThisWorkbook.Save

    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

End Sub

Sub createJpg(Namesheet As String, nameRange As String, nameFile As String)

    ThisWorkbook.Activate

    Worksheets(Namesheet).Activate

    Set Plage = Workbooks("WS TemplateV2.xlsm").Worksheets("3.Shipment details")(Namesheet).Range(nameRange)

    Plage.CopyPicture

        With ThisWorkbook.Worksheets(Namesheet).ChartObjects.Add(Plage.Left, Plage.Top, Plage.Width, Plage.Height)

        .Activate
        .Chart.Paste
        .Chart.Export Environ$("temp") & "\" & nameFile & ".jpg", "JPG"

    End With

    Worksheets(Namesheet).ChartObjects(Worksheets(Namesheet).ChartObjects.Count).Delete

Set Plage = Nothing

End Sub
 
Upvote 0
The sheet its trying to take a picture of is

Workbooks("WS TemplateV2.xlsm").Worksheets("3.Shipment details")

Dont know if this is the problem and what needs to be changed
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,580
Members
452,653
Latest member
craigje92

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top