Send outlook email with excel form on email body (1 Viewer)

Leo_Polla_Psemata

Registered User.
Local time
Today, 12:15
Joined
Mar 24, 2014
Messages
308
Hi there
The below code is the simplified version, the full version is much more complicated with many iifs, however it works just fine, no need to bother you.
Then, after email is displayed on screen and user is about to click send, we click another button, <<Private sub Opexcel1()>>
which creates and outlines an excel consisted of 3 colons and 12 lines, i copy this excel part and paste it on the email body.
Then we send the email with this excel form on its body.
This is an application for special rates, we need approval by specific department(s), management, different each time based on the nature
of the request however the format is always the same.

The question is.
Could I just click one sub , the <<Private Sub EmailOut_Click()>> in our case , and combine the <<Private sub Opexcel1()>>
so in my email i find on the body, the text and the excel form? No need to click another btn and copy paste ?


Code:
Private Sub EmailOut_Click()

    Dim Msg1 As String
        Msg1 = "Dear XXXX" & ", <p>" & "Please review and approve this one" & ", <p>"

    Dim O As Outlook.Application
    Dim M As Outlook.MailItem

    Set O = New Outlook.Application
    Set M = O.CreateItem(olMailItem)

        With M
            .BodyFormat = olFormatHTML
            .HTMLBody = Msg1 & ", <p>"
' ****** Below body first lines, i want to display an excel form consisted of 12 lines , 3 coloun, i
            .To = "tsa@gmail.com"
            .CC = "esp@gmail.com"
            .Subject = "DRQ" & MyRequest & ".Rate approval request  -" & CustN & " - CPF ID: " & CPFID & " - Validity:" & "From:" & ValidFrom & " Up to:  " & ValidTo &  & "//" & Volume
            .Display
          
        End With

    Set M = Nothing
    Set O = Nothing

End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:15
Joined
Sep 21, 2011
Messages
10,612
Do not see why not?
What have you tried?
 

Leo_Polla_Psemata

Registered User.
Local time
Today, 12:15
Joined
Mar 24, 2014
Messages
308
Do not see why not?
What have you tried?

I don't know what syntax should i use after ".HTMLBody = Msg1 & ", <p>" "

There is one existing working perfectly sub (Private sub Opexcel1()) which once i call, one excel pops up in my screen.
What should I do in order to see this excel object displayed in the email body ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:15
Joined
Sep 21, 2011
Messages
10,612
I don't know what syntax should i use after ".HTMLBody = Msg1 & ", <p>" "

There is one existing working perfectly sub (Private sub Opexcel1()) which once i call, one excel pops up in my screen.
What should I do in order to see this excel object displayed in the email body ?
You would need to append it, but with html delimiters as your email is HTML.

I would fall back on my old friend Google to find out how I could do it.

I was thinking you could paste manually and then inspect the source, but the above would be a good start?

Alternatively, just add each item of data with the html code, likely a table format?
 
Last edited:

Users who are viewing this thread

Top Bottom