View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
nbaj2k[_22_] nbaj2k[_22_] is offline
external usenet poster
 
Posts: 1
Default Automatically attach Excel spreadsheet to Outlook Email with Macro?


I can't get to that site from here at work.

I have looked at code around and pieced some things together this is
what I have so far, I still have no idea how to attach the current file
I'm in automatically.

Any other ideas?

The bolded line is the one I somehow want to change to make it
automatically pick the sheet I'm in to attach so I don't have to pick
it.

Thanks,

~J

Sub Email()
Dim myattachment
Dim olNs As Object
Dim olMailItem
Dim olMail As Object
Dim olApp As Object
Dim ATTACH1 As String


ATTACH1 = APPLICATION.GETOPENFILENAME(\"TEXT FILES (*.*), *.*\")
Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon
Set olMail = olApp.CreateItem(olMailItem)
olMail.Display

olMail.To = "(ADDRESS)"
olMail.CC = "(ADDRESS)"
'olMail.BCC =
olMail.Subject = "Daily Report for: " & Format(Date - 1, "d-mmm-yy")
olMail.Body = vbCr & vbCr & "(TEXT HERE)" & Format(Date, "d-mmm-yy") &
"
Set myattachment = olMail.Attachments
myattachment.Add ATTACH1
Stop
'olMail.Send
olNs.Logoff
Set olNs = Nothing
Set olMail = Nothing
Set olApp = Nothing
End Sub


--
nbaj2k
------------------------------------------------------------------------
nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
View this thread: http://www.excelforum.com/showthread...hreadid=562416