Attachment code won't work

R

Ray

Hi

I posted this in a access group and then later read a response to another
question that made me realise I should have posted here. Sorry about the
double post.

I have been trying to modify some code I picked up from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/html/odc_ac_olauto.asp

I am uing Office 2003

I have modified most of it to run referencing my form but the attachment
section doesn't work properly. I hope someone can help me

The original code section is as follows

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

When I first tested the code as the web article suggested it worked fine but
now that I have modified it to read from my form it doesn't work

' Add attachments to the message.
If Not IsNull([fsfrSupportersMessage].[Form]![fAttachment]) Then
Set objOutlookAttach =
..Attachments.Add([fsfrSupportersMessage].[Form]![fAttachment])
End If

No matter what I try objOutlookAttach always show as being
"objOutlookAttach = Nothing" Yet when I point at
([fsfrSupportersMessage].[Form]![fAttachment]) the correct path is reported.

The error message reads "438 Object doesn't support this property or method"

Please I am confused and can't seem to see my way forward on this one. Any
help would be very much appreciated.

Ray
 
G

Guest

Could you please show all of your relevant code? A lot of variable
declarations are missing, so it is difficult to troubleshoot without them.

It might be as simple as the double dot in "..Attachments.Add". Also, what
is a sample value from the [fsfrSupportersMessage].[Form]![fAttachment] field?

Can you compile your module without errors?
 
S

Sue Mosher [MVP-Outlook]

Is it possible that your With statement is in the wrong place or has some
other problem? You didn't show it. Also, what happens if you explicitly set
a string variable to the path:

strPath = [fsfrSupportersMessage].[Form]![fAttachment]
If not strPath = "" Then
Set objOutlookAttach = .Attachments.Add(strPath)
End If
 
R

Ray

Thanks Sue

Your suggestion worked after I added Dim strPath As String

I am a bit in the dark as to why the orginal version doesn't work and this
does, would you mind helping me understand this issue or could you point me
to somewhere I can find the explanation.

Many thanks for the help already given.

Ray

Sue Mosher said:
Is it possible that your With statement is in the wrong place or has some
other problem? You didn't show it. Also, what happens if you explicitly
set a string variable to the path:

strPath = [fsfrSupportersMessage].[Form]![fAttachment]
If not strPath = "" Then
Set objOutlookAttach = .Attachments.Add(strPath)
End If

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Ray said:
Hi

I posted this in a access group and then later read a response to another
question that made me realise I should have posted here. Sorry about the
double post.

I have been trying to modify some code I picked up from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/html/odc_ac_olauto.asp

I am uing Office 2003

I have modified most of it to run referencing my form but the attachment
section doesn't work properly. I hope someone can help me

The original code section is as follows

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

When I first tested the code as the web article suggested it worked fine
but
now that I have modified it to read from my form it doesn't work

' Add attachments to the message.
If Not IsNull([fsfrSupportersMessage].[Form]![fAttachment]) Then
Set objOutlookAttach =
.Attachments.Add([fsfrSupportersMessage].[Form]![fAttachment])
End If

No matter what I try objOutlookAttach always show as being
"objOutlookAttach = Nothing" Yet when I point at
([fsfrSupportersMessage].[Form]![fAttachment]) the correct path is
reported.

The error message reads "438 Object doesn't support this property or
method"

Please I am confused and can't seem to see my way forward on this one.
Any
help would be very much appreciated.

Ray
 
R

Ray

Thanks Eric

Sue's suggestion has done the trick. I don't understand why but it is
working. See response to her post.

Many thanks for taking the time to respond.

Ray

Eric Legault said:
Could you please show all of your relevant code? A lot of variable
declarations are missing, so it is difficult to troubleshoot without them.

It might be as simple as the double dot in "..Attachments.Add". Also,
what
is a sample value from the [fsfrSupportersMessage].[Form]![fAttachment]
field?

Can you compile your module without errors?

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

Ray said:
Hi

I posted this in a access group and then later read a response to another
question that made me realise I should have posted here. Sorry about the
double post.

I have been trying to modify some code I picked up from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/html/odc_ac_olauto.asp

I am uing Office 2003

I have modified most of it to run referencing my form but the attachment
section doesn't work properly. I hope someone can help me

The original code section is as follows

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

When I first tested the code as the web article suggested it worked fine
but
now that I have modified it to read from my form it doesn't work

' Add attachments to the message.
If Not IsNull([fsfrSupportersMessage].[Form]![fAttachment]) Then
Set objOutlookAttach =
..Attachments.Add([fsfrSupportersMessage].[Form]![fAttachment])
End If

No matter what I try objOutlookAttach always show as being
"objOutlookAttach = Nothing" Yet when I point at
([fsfrSupportersMessage].[Form]![fAttachment]) the correct path is
reported.

The error message reads "438 Object doesn't support this property or
method"

Please I am confused and can't seem to see my way forward on this one.
Any
help would be very much appreciated.

Ray
 
S

Sue Mosher [MVP-Outlook]

I think the answer would lie in what this expression returns:

[fsfrSupportersMessage].[Form]![fAttachment]

Those of us who can't see your form can only guess.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Ray said:
Thanks Sue

Your suggestion worked after I added Dim strPath As String

I am a bit in the dark as to why the orginal version doesn't work and this
does, would you mind helping me understand this issue or could you point
me to somewhere I can find the explanation.

Many thanks for the help already given.

Ray

Sue Mosher said:
Is it possible that your With statement is in the wrong place or has some
other problem? You didn't show it. Also, what happens if you explicitly
set a string variable to the path:

strPath = [fsfrSupportersMessage].[Form]![fAttachment]
If not strPath = "" Then
Set objOutlookAttach = .Attachments.Add(strPath)
End If

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Ray said:
Hi

I posted this in a access group and then later read a response to
another question that made me realise I should have posted here. Sorry
about the double post.

I have been trying to modify some code I picked up from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/html/odc_ac_olauto.asp

I am uing Office 2003

I have modified most of it to run referencing my form but the attachment
section doesn't work properly. I hope someone can help me

The original code section is as follows

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

When I first tested the code as the web article suggested it worked fine
but
now that I have modified it to read from my form it doesn't work

' Add attachments to the message.
If Not IsNull([fsfrSupportersMessage].[Form]![fAttachment]) Then
Set objOutlookAttach =
.Attachments.Add([fsfrSupportersMessage].[Form]![fAttachment])
End If

No matter what I try objOutlookAttach always show as being
"objOutlookAttach = Nothing" Yet when I point at
([fsfrSupportersMessage].[Form]![fAttachment]) the correct path is
reported.

The error message reads "438 Object doesn't support this property or
method"

Please I am confused and can't seem to see my way forward on this one.
Any
help would be very much appreciated.

Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top