Solved

Outlook Automation

Posted on 2001-08-22
7
264 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
  • 4
  • 3
7 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 175 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now