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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,222,045
Messages
6,163,587
Members
451,846
Latest member
ajk99

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