VBA Send To Mail Recipient

marka87uk

Board Regular
Joined
Mar 24, 2007
Messages
247
Hi,

I've coded a macro which processes some data, and when this is done I would like to get it ready to be emailed.

How would be an easy way of going about this? We use Outlook, and I was thinking it would probably be best to do the same as clicking on Send To > Mail Recipient would, but I'd the fields such as To and Subject to be filled in automatically.

For now I'd prefer it to not send the mail, but just to fill in the fields. :)
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

ageren

Board Regular
Joined
Jul 30, 2007
Messages
60
copy below code in your macro module...


sub send_mail ()

Dim Out As Object

Set Out = CreateObject("Outlook.Application")
With Out.CreateItem(olMailItem)

.Recipients.Add "xxxxx.yyyy@yahoo.com" 'refers TO line of your outlook..
.Subject = "book of electronic fund transfer" ' refers SUBJECT ...
.Body = "please find attached the EFT workbook" ' body of your mail
.Attachments.Add "c:\eft.txt" ' attachement line of your mail
.send ' sends your mail ...
End With

end sub
 

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
This will help you, lots of choices or just download the sample workbooks:

http://www.rondebruin.nl/sendmail.htm

If you change the .Send to .Display you can check how your email looks when your code is set up....then chsnge it back to .Send

If you need more help post back.
 

Forum statistics

Threads
1,181,649
Messages
5,931,215
Members
436,784
Latest member
amuljono

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
Top