Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Outlook Automation

Posted on 2001-08-22
7
Medium Priority
?
273 Views
Last Modified: 2008-02-01
I Need help with this; pronto!!

I get this error message. (when it hits the .Attachments.Add strAttachmentPath line)
____________________________________________________
Debug.Print Err.Number & " - " & Err.Description
-2147352567 - Cannot add the attachment; no data source was provided.
____________________________________________________
I have tried this through these two environments and i get identical errors:

1. Win95, Office 97, Access 97
2. Win2K, Office 2K, Access 2K

I need to have this done yesterday, please help???

206 694 6384
206 694 6384
206 694 6384
206 694 6384
206 694 6384
_____________________________________________________

Public Function SendEmail(strSubject As String, strEmailAddress As Variant, strMessage As Variant, strAttachmentPath As String)
On Error GoTo ErrHandler


Dim oLapp As Object
Dim oItem As Object
Dim oNameSpace As Object

Set oLapp = CreateObject("Outlook.application")
Set oNameSpace = oLapp.GetNamespace("MAPI")
Set oItem = oLapp.CreateItem(0)


Dim objNameSpace
Dim objOutlookApp
Dim objItem

With oItem
    .Subject = strSubject
    .To = strEmailAddress
    .Body = strMessage
If Not IsNull(strAttachmentPath) = True Then
    .Attachments.Add = strAttachmentPath
End If
    .Send

End With

__________________________________
PS - At this site
http://www.windows.hu/10makro.html
I found arguments at the end of the corresponding attachment line.. Can someone help me with the hungarian?
_________________________________

Dim objNameSpace
Dim objOutlookApp
Dim objItem

Set objOutlookApp = CreateObject("Outlook.Application")
Set objNameSpace = objOutlookApp.GetNameSpace(,MAPI")
Set objItem = objOutlookApp.CreateItem(0) 'MailItem
objItem.To = "karenk@winmag.com"
objItem.Attachements.Add "C:\WinMag.log", 1, , _
"WinMag Log File"
objItem.Subject = "WinMag Log File"
objItem.Display
objItem.Send
Wscript.Quit
'Mail From WSH
0
Comment
Question by:AAMFK
[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
  • 4
  • 3
7 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 700 total points
ID: 6416152
Add is a Method of the Attachment object not a Property.  In other words lose the = sign.

Your code should be as follows:

.Attachments.Add strAttachmentPath
0
 
LVL 1

Author Comment

by:AAMFK
ID: 6416159
goddangit.

can I bear your children?
0
 
LVL 1

Author Comment

by:AAMFK
ID: 6416166
thank you so very much, acperkins...

ps - can i ask what city you are in? (just trust me on this, ok?)
0
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.

 
LVL 1

Author Comment

by:AAMFK
ID: 6416169
just the answer i needed, when i needed it.
thank you!!!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6416171
I live in the DFW area.  Got a job opening for me somewhere in the US? <smile>

By the way here is the code (somewhat modified) that I use.  It uses early binding which is more efficient:

Public Sub SendMail(Recipients() As String, _
                              Optional Subject As String = "", _
                               Optional MsgText As String = "", _
                               Optional Attachment As String = "")
                               
Dim objMail As Outlook.Application
Dim objItem As Object
Dim objRecipient As Outlook.Recipient
Dim I As Integer
Dim RecipientName As String

On Error GoTo ErrHandler

Set objMail = New Outlook.Application
With objMail
   Set objItem = .CreateItem(olMailItem)
   With objItem
      For I = LBound(Recipients) To UBound(Recipients)
         Set objRecipient = .Recipients.Add(Recipients(I))
         With objRecipient
            .Type = CdoTo
            If Not .Resolve Then
               objItem.Display
            End If
         End With
      Loop
      If .Recipients.Count > 0 Then
         .Subject = Subject
         .Body = MsgText
         If Len(Attachment) Then
            .Attachments.Add Attachment
         End If
         .send
         Set objRecipient = Nothing
      End If
   End With
   Set objItem = Nothing
End With
Set objMail = Nothing

Exit Sub

ErrHandler:
'Exchange is probably down (again).
If Not objMail Is Nothing Then
   Set objMail = Nothing
End If

End Sub

Anthony
0
 
LVL 1

Author Comment

by:AAMFK
ID: 6416193
i like it.. i don't understand the

If Not .Resolve Then

Does that have to do with classes?

basically im dedicating a few old machines for this and broadcast faxing.... and were trying to do this all on ""INTERNET TIME"" although that is passe from four years ago..


im in seattle; but i was gonna offer you sandwiches delivered (www.briazz.com) to CHI/LAX/SFO/SEA; etc..

But im not sure theyd be fresh when they got to texas.. (PS - how is the sandwich market in DFW?  like seriously--  is there a lot of competition; is quiznos down there; etc?)

im not sure about the position...

were moving to a new pos system and having a second contractor come in starting monday. it all depends on how he works out..

aaronk@briazz.com

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6683407
Sorry, just got round to reading your response.  Who knows what happened!

As you must have figured out already <smile>, the Resolve method matches your partial entry with your address book. Somewhat analogous to Check Names (Alt+K) in Outlook.

Quiznos is here, as well as Schlotzky, Subway and a few others like Jason's which may be local brews.

How is the second contractor working out?

Anthony
acperkins@tutopia.com
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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

670 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