Excel template to send a standardised mail

MaxTiger

New Member
Joined
Nov 19, 2018
Messages
4
Hi all,

I like to experiment in excel to learn new things (as I am still relatively unexperienced), but sometimes I feel I am trying to reinvent the wheel. This is also the case for what I am trying to accomplish right now.

See, I want to create an excel template with “fill-in-the-blanks” boxes to create a standardized outlook e-mail for purchase requests for me and my colleagues. When the blanks are filled in, the user of the excel (e.g. me) only has to push a “send” button. Then, when the superior that has authorization to actually purchase the indicated products receives the mail, he can easily fulfil the request (easy, because of a standardised form for requests).

The request format should generate a mail looking something like this, with the underlined text as filled-in blanks:

''

Hi Richard,

I have the following purchase request(s) for you, regarding the production of apple pies.

Product IDProduct descriptionQuantitySupplier IDReq. delivery date
22023Butter2076Monday, April 29
83391Pastry9339Friday, April 26
4653Eggs5023Monday, May 6
etc.----

<tbody>
</tbody>


If you have any questions about my order request, please contact me on 079-44251826.

Thank you in advance,

Greetings Max


''


I think you get the idea. It seems very likely to me that someone, somewhere already ‘developed’ something very similar to this. I hope that that someone can share this with me, so I can tweak it to my intended use. Thank you in advance!

Max
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
.
Paste into a Regular Module :

Code:
Option Explicit


Sub send_email_via_outlook()


' Tools - Refrence - Microsoft Outlook
Dim olApp As New Outlook.Application
Dim olMail As MailItem


Set olMail = olApp.CreateItem(olMailItem)
    
    With olMail
        .To = "myemail@yahoo.com"
        .CC = ""
        .Subject = "Send Range as table in outlook"  '<br> used to insert a line ( press enter)
        .HTMLBody = "Hi Richard, <br> <br>" & "I have the following purchase request(s) for you, regarding the production of " & Sheet1.Range("G2").Value & ".<br><br> " & _
                    create_table(Sheets("Sheet1").Range("A1").CurrentRegion) & _
                    "</Table><br> <br>If you have any questions about my order request, please contact me on 079-44251826. <br> <br>" & _
                    "Thank you in advance,<br> <br>" & _
                    "Greetings Max<br><br>"
        .Display
        '.Send
    End With




End Sub


Function create_table(rng As Range) As String


Dim mbody As String
Dim mbody1  As String
Dim i As Long
Dim j As Long


' for html color codes list visit http://www.w3schools.com/html/html_colornames.asp


mbody = "<TABLE width=""65%"" Border=""1"", Cellspacing=""0""><TR>" ' configure the table


'create Header row
For i = 1 To rng.Columns.Count
    mbody = mbody & "<TD width=""100"", Bgcolor=""#A52A2A"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:18px"">" & rng.Cells(1, i).Value & " </p></Font></TD>"
Next


' add data to the table
For i = 1 To rng.Rows.Count
    mbody = mbody & "<TR>"
    mbody1 = ""
    For j = 1 To rng.Columns.Count
    mbody1 = mbody1 & "<TD><center>" & rng.Cells(i, j).Value & "</TD>"
    Next
    mbody = mbody & mbody1 & "</TR>"
Next


create_table = mbody
End Function

Download workbook : https://www.amazon.com/clouddrive/share/slBxxdMjF9OrvIPeenoRgZJ7rzVI6qCHuPrJ9aYqyea
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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