Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Error sending Outlook 2007 email from Access 2007 on XP

Posted on 2012-04-03
10
Medium Priority
?
222 Views
Last Modified: 2012-04-12
My application can send Outlook 2007 email from Access 2007 on Vista or Windows 7 but when I try to run it on XP I get the "%1 is not a valid Win32 application" error. Any thoughts other than upgrading the XP machine?
0
Comment
Question by:jnero
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37801357
I run Access 2007 with email automation all the time with no issues...

Is this win xp machine fully updated...?
Did you develop the app in a 64 bit OS?

Can you post your code?

A general rule is to always develop in/for the lowest configuration.
For example if you develop an app in Access 2007, win 7 64 bit, who is to say that it will work in Win 3.0, Win 2000? Win Millienum,..et al?
If you even think that you might have to support a lower system, then develop for that system (if at all possible)
0
 

Author Comment

by:jnero
ID: 37801450
Thanks.  The problem may be that I developed it on the Windows 7 machine, which is definitely 32 Bit, I edited it further on the Vista machine, which I don't believe is 64 bit, but I can check that tonight.

The XP machine is running 5.1.2600 Service Pack 3- Build 2600

Here is the code:

Private Sub Sendemail_Click()

   Dim stDocName As String
   Dim stLinkCriteria As String
If Not IsNull(FaceID) Then
   stDocName = "frmFaces"
   stLinkCriteria = "FaceID=" & Forms![frmMaster2]![frmTransactionSubform].Form![With Whom]
   
   DoCmd.OpenForm stDocName, , , stLinkCriteria
 
End If
   
     DoCmd.OpenForm "frmFaces"
    Dim t As String
    t = Forms![frmFaces].EMAIL
    DoCmd.Close
    DoCmd.OpenForm "frmMaster2"
         
Dim MyOutlook As Outlook.Application
Dim MyEmail As Outlook.MailItem
 
Set MyOutlook = CreateObject("Outlook.application")
Set MyEmail = MyOutlook.CreateItem(olMailItem)

MyEmail.To = t
MyEmail.Subject = Forms![frmMaster2].Form![Headline]
MyEmail.body = Forms![frmMaster2]![frmTransactionSubform].Form![Notes] & vbCrLf & GetSignature("PR")
 
MyEmail.display

Dim Clip As String
Dim textonly As String

Clip = Forms![frmMaster2].Form![Headline] 'make the line shorter for coding purposes
textonly = InStr(Clip, "#")
Clip = Replace(Clip, "#", "") 'remove the #s
MyEmail.Subject = Mid(Clip, 1, textonly - 1)
   
End Sub

   Function GetSignature(strSignatureName As String) As String
    Const ForReading = 1
    Const TriStateTrue = -1
    Dim objFSO As Object, objFile As Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(Environ("USERPROFILE") & "\Application Data\Microsoft\Signatures\" & strSignatureName & ".txt", ForReading, False, TriStateTrue)
    GetSignature = objFile.ReadAll
    objFile.Close
    Set objFile = Nothing
    Set objFSO = Nothing
   

End Function
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37801855
what line are you getting the error on...?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jnero
ID: 37801872
Set MyOutlook = CreateObject("Outlook.application")
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37802260
Are you loading a reference to the Microsoft Outlook Object Library in your VBE?

In other words, if we remove all the extraneous stuff and jsut focus on the Email...
Then something like this should work fine:
Code modified from here:
http://support.microsoft.com/kb/161088

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
        ' Add the To recipient(s) to the message.
        Set objOutlookRecip = .Recipients.Add("SomeEmailAddress")
        objOutlookRecip.Type = olTo
       
        ' Set the Subject, Body, and Importance of the message.
        .Subject = "This is an Automation test with Microsoft Outlook"
        .Body = "This is the body of the message."
   
       
        ' Resolve each Recipient's name.
        For Each objOutlookRecip In .Recipients
            objOutlookRecip.Resolve
        Next
       
        .Display
    End With

Set objOutlook = Nothing
0
 

Author Comment

by:jnero
ID: 37802346
I have been loading the reference to the Microsoft Outlook Object Library.  

Tried the new code and still get the error here:
Set objOutlook = CreateObject("Outlook.Application")
0
 

Author Comment

by:jnero
ID: 37802361
If it makes a difference, I had the same script running fine when I was running Access 2003 on this XP machine.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 1500 total points
ID: 37802433
Then something is seems awry with that XP machine...

Can you try this on another PC with Win XP?

Again I run Outlook automation via Acc 2007 and Win XP all the time, with no issues
0
 

Author Comment

by:jnero
ID: 37802869
Good idea -- I do have another XP machine. Will try that tonight. Thanks.
0
 

Author Comment

by:jnero
ID: 37815844
Unfortunately the other XP machine was running OLK 2003 and the problem is with 2007, so I have some reloading to do. Will update next week.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

618 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