Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default E-Mail attachments

I am trying to write and e-Mail with an attachment pointing to another file.
When I run this code, it tells me it is running; but when I look in the
folder, I have an empty folder. I am submitting the code for anyone can tell
me why I am having problems. Thank you any assistance someone can give me.

Sub SendWithAtt()
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim olAttach As Attachment
Dim olFolder As Outlook.MAPIFolder
Dim olNameSpace As Outlook.Namespace

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olFolder = olNameSpace.GetDefaultFolder(olFolderInbox)

With olMail
.To = "
.CC = ""
.BCC = ""
.Subject = "Transmission of Special Item Inventory File"
.Body = "The Special Item Inventory File is now being
transmitted."

If Len("c:\Inventory\Transmit\TransInv.mdb") < 0 Then
For Each olAttach In olMail.Attachments
olAttach.SaveAsFile "c:\Prod\Data\Inventory\" &
olAttach.Filename
Next
Else
'Note: Place here messages that the files doesn't exists
End If
.Display
.Send
End With

Set olMail = Nothing
Set olApp = Nothing
Set olAttach = Nothing
Set olFolder = Nothing
Set olNameSpace = Nothing
End Sub

--
Larry E. Brueshaber
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default E-Mail attachments

I can not comment your code. But take a look at
http://www.rondebruin.nl/sendmail.htm

Hopefully the example code will help you further!

Martin

"Larry" wrote:

I am trying to write and e-Mail with an attachment pointing to another file.
When I run this code, it tells me it is running; but when I look in the
folder, I have an empty folder. I am submitting the code for anyone can tell
me why I am having problems. Thank you any assistance someone can give me.

Sub SendWithAtt()
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim olAttach As Attachment
Dim olFolder As Outlook.MAPIFolder
Dim olNameSpace As Outlook.Namespace

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olFolder = olNameSpace.GetDefaultFolder(olFolderInbox)

With olMail
.To = "
.CC = ""
.BCC = ""
.Subject = "Transmission of Special Item Inventory File"
.Body = "The Special Item Inventory File is now being
transmitted."

If Len("c:\Inventory\Transmit\TransInv.mdb") < 0 Then
For Each olAttach In olMail.Attachments
olAttach.SaveAsFile "c:\Prod\Data\Inventory\" &
olAttach.Filename
Next
Else
'Note: Place here messages that the files doesn't exists
End If
.Display
.Send
End With

Set olMail = Nothing
Set olApp = Nothing
Set olAttach = Nothing
Set olFolder = Nothing
Set olNameSpace = Nothing
End Sub

--
Larry E. Brueshaber

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Templates as e-mail Attachments? Excel Template as an e-mail Attachment Excel Discussion (Misc queries) 0 September 5th 07 10:56 PM
E-mail Multiple Attachments STEVEB Excel Programming 2 December 2nd 05 03:17 PM
Blocked e-mail attachments LB[_4_] Excel Programming 4 October 1st 05 02:00 PM
Creating TWO-WAY E-Mail Attachments with 'BeforeSave Events' in Code for 2nd E-Mail Chuckles123[_112_] Excel Programming 0 September 8th 05 05:56 PM
E-mail Attachments STEVEB Excel Programming 1 August 23rd 05 02:27 PM


All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"