CCkfm2000
06-17-2005, 09:41 AM
: pray2: hi all..
i've found some vba code to send email's from excel ( see code below ).
what i need is to run outlook before the code or check if outlook is already running. then run the code.
many thanks :friends:
Option Explicit
Sub Mail_ActiveSheet_Outlook()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim WB As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set WB = ActiveWorkbook
With WB
.SaveAs "Part Of ..." & ThisWorkbook.Name _
& " " & strdate & ".xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "a_user@anywhere.com"
'.CC = ""
'.BCC = ""
.Subject = "stats 2005"
.Body = "See Attached File Please...."
.Attachments.Add WB.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
i've found some vba code to send email's from excel ( see code below ).
what i need is to run outlook before the code or check if outlook is already running. then run the code.
many thanks :friends:
Option Explicit
Sub Mail_ActiveSheet_Outlook()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim WB As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set WB = ActiveWorkbook
With WB
.SaveAs "Part Of ..." & ThisWorkbook.Name _
& " " & strdate & ".xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "a_user@anywhere.com"
'.CC = ""
'.BCC = ""
.Subject = "stats 2005"
.Body = "See Attached File Please...."
.Attachments.Add WB.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub