Generating automatic e-mails using excel data through VBA (outlook application)

Improvedfly

New Member
Joined
Dec 13, 2017
Messages
1
Hello All,

Please let me start by saying that this is my first post after years of using these forums to learn excel when I only knew "Sum(A1:B2)". Thank you!

I have spent a couple of days going through the best way to code something I have made to make my life easier at work.
Essentially what I want to do is press a button and generate two mails: one for the customer and one for the supplier.
How I have designed the structure of things is through mainly using vlook-up (Application.WorksheetFunction.Vlookup ...).

Email 1: Customer
Table A4:C6 contains the choice number, customer name and the price. In cell H4 (in yellow) I will put my choice number and in doing so it will store the name of the customer in column "B". For example I put 2 in H4 and the code will know that I have selected "Customer 2". In a sheet named "Contacts" I also have a table A1:B10 with customer names and an e-mail address to each customer. So whatever I choose in H4, the program will vlookup the customer name in the table A4:C6, find out what supplier name I am talking about and generate an outlook mail with email taken from Worksheets."Contacts".Range("A1:B10"). "To: Customer_2@vba.com".
In the body of the text I want to copy a table (say A16:E24) and paste it after my text in the body of the mail.

Email 2: Supplier
Table A4:D6 will contain the supplier column this time and when requesting the 1st choice in cell I4, the program will do the same thing. It will store the fact that I have chosen "Supplier 2" , vlookup his name in the sheet called "Contacts" range("A1:B10") and generate an e-mail "To: Supplier_2@vba.com".

Subject of both e-mails:
The subject will be "Order" & cell "B10" & "for delivery date" & "B9".

I have attached an image of the main table, perhaps it would be useful to visualize.
Thank you immensely for the help guys.

Flickr photo: https://www.flickr.com/photos/155082293@N06/24173381987/in/dateposted-public/
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

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