Send as attachement

smods

Board Regular
Joined
Feb 18, 2008
Messages
79
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I have a worksheet which users fill in. I want to put a command button on it which when clicked will e-mail the file as an attachment but not send it and not specify any specific e-mail address.

So I click the button it opens an e-mail in outlook with the file attached ready for me to type my recipients in.

I also want to add some validation. So if B1 is blank then and the user clicks to e-mail then it says hang on B1 is blank or if B5 is empty, hang on B5 is empty

Any help would be much appreciated

Chris
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
So if I want to use

Code:
[FONT=Arial][B]Sub Mail_workbook_Outlook_1()[/B][COLOR=#000080]'Working in 2000-2007'This example send the last saved version of the Activeworkbook[/COLOR]    Dim OutApp As Object    Dim OutMail As Object[/FONT]</PRE>
 </PRE>
[FONT=Arial]    Set OutApp = CreateObject("Outlook.Application")    OutApp.Session.Logon    Set OutMail = OutApp.CreateItem(0)[/FONT]</PRE>
 </PRE>
[FONT=Arial]    On Error Resume Next    With OutMail        .To = "ron@debruin.nl"        .CC = ""        .BCC = ""        .Subject = "This is the Subject line"        .Body = "Hi there"        .Attachments.Add ActiveWorkbook.FullName[COLOR=#000080]        'You can add other files also like this        '.Attachments.Add ("C:\test.txt")[/COLOR]        .Send  [COLOR=#000080] 'or use .Display[/COLOR]    End With    On Error GoTo 0[/FONT]</PRE>
 </PRE>
[FONT=Arial]    Set OutMail = Nothing    Set OutApp = NothingEnd Sub[/FONT]</PRE>

How to do I do this with the validation mentioned? What is the full code, I'm moving bits about but I just can't get the code to work due to my lack of knowledge. Please help Chris!
 
Upvote 0
The code I posted will go before the code from the website I directed you to. If B1 is blank, a message box will be displayed and the code will terminate. The next part of the code (from the website) will only run if B1 is not blank.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,664
Members
449,045
Latest member
Marcus05

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