?
Solved

Error sending Outlook 2007 email from Access 2007 on XP

Posted on 2012-04-03
10
Medium Priority
?
220 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

764 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