Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.SendObject - Email wont send

Status
Not open for further replies.

AndyHorn

Technical User
Feb 12, 2003
49
0
0
GB
Hi,

I've written the following code to grab information on the open form in access and put it into an email with a snapshot attachment. This works fine but when I click the send button on the email it doesn't do anything. The only way to get it to work is to save the email, open it again and then press send.

I'm using Office 2000 pro with Outlook 2003. Both are patched pretty much up to date.

------------------------------------------------------------
Private Sub Command80_Click()

On Error GoTo Err_Command80_Click

Dim Title As Object
Dim Surname As Object
Dim ID As Object
Dim DesDate As Object
Dim RetOrRep As Object
Dim Item As Object
Dim Reason As Object
Dim Note As Object

Set Title = [Forms]![FormName]![Title]
Set Surname = [Forms]![FormName]![Surname]
Set ID = [Forms]![FormName]![ID]
Set DesDate = [Forms]![FormName]![SubFormName].Form![DespatchDate]
Set RetOrRep = [Forms]![FormName]![SubFormName].Form![Returned or Replaced?]
Set Item = [Forms]![FormName]![SubFormName].Form![WhichProduct?]
Set Reason = [Forms]![FormName]![SubFormName].Form![Fault]
Set Note = [Forms]![FormName]![SubFormName].Form![Notes]

DoCmd.SendObject acSendReport, "ProductReturnReport", "SnapshotFormat(*.snp)", "me@company.com", , , Title & " " & Surname & " cn " & ID & " dd " & DesDate & " " & StrConv(RetOrRep, vbUpperCase) & " " & Item & " " & StrConv(Reason, vbUpperCase), Note, True

Set Title = Nothing
Set Surname = Nothing
Set ID = Nothing
Set DesDate = Nothing
Set RetOrRep = Nothing
Set Item = Nothing
Set Reason = Nothing
Set Note = Nothing

Exit_Command80_Click:
Exit Sub

Err_Command80_Click:
MsgBox err.Description
Resume Exit_Command80_Click

End Sub
------------------------------------------------------------

Any suggestions as to why it wont send are welcome.
Thanks
 
Do you have all ther service releases applied for office2000. Sendobject was broken in the initial release of A2000.

Your Objects should all be Strings. Then you need to remove all the 'Set's and just use variable assignments:
Title = [Forms]![FormName]![Title]
etc

You do not need any of the 'Set..object ..= nothing' statements.
 
The point about using strings and therefore not using Set commands is well made and the solution may well work after doing this.

However if you are running on XP SP2 then you will have the advanced security features installed in Outlook 2003 and these may prevent you from sending emails in this way.

Go to for a tool that overcomes this problem.



Bob Boffin
 
I've amended the code as suggested but the email still wont send.

Office 2000 is up to date with service packs etc.

Thanks for the tips on the code. I'm learning all the time.
I did have the 'objects' as 'strings' at one point but had an error message so tried them as objects and the error went away. I've put them back to strings and it still creates the email ok.

Should a memo field be dimmed as a variant? I've tried 'string' and 'object' but it doesn't like them.
 
Memo fields are usually OK as strings and a VB String is plenty large enough to accommodate it. Using a Variant should also work but is less efficient.

I've just noticed that the third parameter to the SendObject call appears to be wrong. According to the Help for Access 2000 it would need to be one of acFormatDAP, acFormatHTML, acFormatRTF, acFormatTXT, acFormatXLS or blank.

In this case acFormatRTF would be appropriate.

I also wonder if the that the report file is larger than any limit imposed on the size of attachments by your mail server? Commonly this limit is 2Mb.


Bob Boffin
 
Yes, the standard attachment types are as you've suggested but don't really work for me, a snapshot is preferred. I previously had a macro doing a very similar task. In the macro it let you choose a snapshot as the attachment. Because this isn't available as a standard command in the sendobject command I converted the macro to VBA to see how it would attach the snapshot file. I then copied and pasted "SnapshotFormat(*.snp)", and it worked fine. The email is created perfectly with the snapshot file attached, 60kb, but the Send button on the email just doesn't do anything.

I use XP with SP2, however most of the other workstations that will be using this use Win2K (SP4). I think you were along the right lines about it being a security feature but within Outlook 2003. I guess the users will just have to put up with saving it, then sending it. It beats typing it everytime!

Thanks for all your suggestions. I'll accept there's not much I can do but if anyone thinks of something else feel free to post it.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top