[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Error sending Outlook 2007 email from Access 2007 on XP

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
jnero
Asked:
jnero
  • 6
  • 4
1 Solution
 
Jeffrey CoachmanCommented:
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
 
jneroAuthor Commented:
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
 
Jeffrey CoachmanCommented:
what line are you getting the error on...?
0
Industry Leaders: 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!

 
jneroAuthor Commented:
Set MyOutlook = CreateObject("Outlook.application")
0
 
Jeffrey CoachmanCommented:
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
 
jneroAuthor Commented:
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
 
jneroAuthor Commented:
If it makes a difference, I had the same script running fine when I was running Access 2003 on this XP machine.
0
 
Jeffrey CoachmanCommented:
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
 
jneroAuthor Commented:
Good idea -- I do have another XP machine. Will try that tonight. Thanks.
0
 
jneroAuthor Commented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now