E-Mail attachments

G

Guest

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 = "(e-mail address removed)"
.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top