For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > October 2004 > Add attachment to email in VB code









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Add attachment to email in VB code
Sean

2004-10-27, 3:55 pm

How can I add an attachment to this email using my code below. txtAttach.Text
is populated with a file path. However it doesn't seem to be working.
I get an error that reads: 'Object doesn't support named arguments' Is
something wrong in the syntax or code?
Thanks,
Sean

********

' email
Dim App
Dim Item
Dim y As Integer

Dim sInFolder() As String
Attachment = txtAttach.Text
Set App = CreateObject("Outlook.Application")
Set Item = App.CreateItem(0)

With Item
.Subject =
.To =
.Cc =
.Body =

If chkAttach.Value = 1 And Len(Attachment > 20) Then
.Attachments.Add Source:=Attachment
End If

.Send

End With
Set App = Nothing
Set Item = Nothing
Veign

2004-10-27, 8:55 pm

Without trying it remove the named argument and replace with something like
this:

..Attachments.Add Attachment

--
Chris Hanscom - Microsoft MVP (VB)
http://www.veign.com
--

"Sean" <Sean@discussions.microsoft.com> wrote in message
news:E9AD4503-F3E2-49E0-9C86-C7217016CA36@microsoft.com...
> How can I add an attachment to this email using my code below.

txtAttach.Text
> is populated with a file path. However it doesn't seem to be working.
> I get an error that reads: 'Object doesn't support named arguments' Is
> something wrong in the syntax or code?
> Thanks,
> Sean
>
> ********
>
> ' email
> Dim App
> Dim Item
> Dim y As Integer
>
> Dim sInFolder() As String
> Attachment = txtAttach.Text
> Set App = CreateObject("Outlook.Application")
> Set Item = App.CreateItem(0)
>
> With Item
> .Subject =
> .To =
> .Cc =
> .Body =
>
> If chkAttach.Value = 1 And Len(Attachment > 20) Then
> .Attachments.Add Source:=Attachment
> End If
>
> .Send
>
> End With
> Set App = Nothing
> Set Item = Nothing



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com