• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Outlook Automation

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
AAMFK
Asked:
AAMFK
  • 4
  • 3
1 Solution
 
Anthony PerkinsCommented:
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
 
AAMFKAuthor Commented:
goddangit.

can I bear your children?
0
 
AAMFKAuthor Commented:
thank you so very much, acperkins...

ps - can i ask what city you are in? (just trust me on this, ok?)
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
AAMFKAuthor Commented:
just the answer i needed, when i needed it.
thank you!!!
0
 
Anthony PerkinsCommented:
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
 
AAMFKAuthor Commented:
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
 
Anthony PerkinsCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now