![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 3
|
Hi All
I work for an International freight forwarding company and we have Outlook and Outlook Express installed. To save printing out the invoice and faxing it I would like to e-mail it directly from my PC to the client as so many now have internet access. Is it possible ???!!! If so HOW?? Your help much appreciated Regards Peter |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,510
|
Save your file, then.
Believe it or not, there's a little envelope icon on your toolbar. Also, File-Send to-Email recipient. And may I strongly suggest you always send as an attachment?
__________________
~Anne Troy |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
|
Try
Sub SendEmail() Dim aOutlook As Outlook.Application, aEmail As Outlook.MailItem On Error Resume Next Set aOutlook = GetObject(, "Outlook.Application") If aOutlook Is Nothing Then Set aOutlook = New Outlook.Application On Error GoTo 0 If aOutlook Is Nothing Then MsgBox "Microsoft Outlook is not installed." Else Set aEmail = aOutlook.CreateItem(olMailItem) aEmail.Subject = "Latest figures" aEmail.Body = "The figures do not include the last two days of trading." aEmail.Attachments.Add ThisWorkbook.Path & "data01.xls" aEmail.Recipients.Add "email@address.com" On Error GoTo lNoSend aEmail.Send MsgBox "Email successfully sent." End If Exit Sub lNoSend: MsgBox "Email not sent." End Sub or Sub SendEmailNR() Dim aOutlook As Object, aEmail As Object On Error Resume Next Set aOutlook = GetObject(, "Outlook.Application") On Error GoTo lNoOutlook If aOutlook Is Nothing Then Set aOutlook = CreateObject("Outlook.Application") Set aEmail = aOutlook.CreateItem(olMailItem) On Error GoTo 0 aEmail.Subject = "Latest figures" aEmail.Body = "The figures do not include the last two days of trading." aEmail.Attachments.Add ThisWorkbook.Path & "data01.xls" On Error GoTo lNoSend aEmail.Recipients.Add "bigman@hotmail.com" aEmail.Send MsgBox "Email successfully sent." Exit Sub lNoSend: MsgBox "Email not sent." Exit Sub lNoOutlook: MsgBox "Microsoft Outlook is not installed." End Sub [ This Message was edited by: brettvba on 2002-03-11 16:35 ] |
|
|
|
|
|
#4 |
|
Guest
Posts: n/a
|
ic
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Posts: 122
|
i tried this and it doesnt work!?
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
With your invoice open click on the visual basic editor or alt+f11. Highlight your project and click insert>module, then paste this code:
Sub SendIt() Application.Dialogs(xlDialogSendMail).Show _ arg1:="email@address.com", _ arg2:="Invoice name" End Sub (arg1 will be the default address, when outlook opens you can change who receives the invoice.) Then close the editor and on your invoice add a command button and set its caption to "Click to send invoice". Right click on the command button and click view code. Then paste this code: Dim Pw As String Pw = InputBox("Enter Password") If Pw = "Whatever you want as password" then SendIt:End If Pw <> "Your password above" Then MsgBox ("Incorrect Password, cannot send mail") End If The above code will prevent others from sending the invoice without your knowledge. (Just make sure to right click on your project file, click on vbaproject properties,and enter a password under the protection so others cannot view your code. Save your workbook and click the button. HTH Viper |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
Sorry,
Make sure to enter the command button code in the click_event. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|