Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sending of attachments with email using VBA in Microsoft Excel

Posted on 2007-03-28
2
Medium Priority
?
169 Views
Last Modified: 2010-04-30
Hello, I am trying to automate the sending of attachments with email using VBA in Microsoft Excel.

I have it working except for the attachment piece, does anyone know how to set it up so I can attach for example "C:\Temp\Text.txt"?  I've attached the code that works without the attachment piece below.

Sub Send_Email()

    Dim objOL As New Outlook.Application
    Dim objMail As MailItem

    Set objOL = New Outlook.Application
    Set objMail = objOL.CreateItem(olMailItem)
       
    With objMail
        .To = "first.last@yahoo.com"
        .CC = ""
        .Subject = "test email"
        .Body = "test line 1" & Chr(10) & Chr(10) _
                & "test line 2" & Chr(10) & Chr(10)
        .Attachments = ("c:\temp\text.txt")
        .Display
    End With
   
    Set objMail = Nothing
    Set objOL = Nothing

End Sub

Thanks
0
Comment
Question by:hpsuser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 2000 total points
ID: 18812915
.Attachments.Add = "c:\temp\text.txt"

Kevin
0
 

Author Comment

by:hpsuser
ID: 18812951
Thanks Kevin, it was Attachments.Add(file), but that was the help I needed!

I'm awarding points, have a good one.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question