Solved

Outlook Automation

Posted on 2001-08-22
7
267 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

830 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