CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2003
    Location
    Holland
    Posts
    146

    Problem with Outlook

    Hi,
    From my project I make a E-mail with attachment and than it goes to the outbox of Outlook.
    This did work a long time good.
    Since about two month I get the error 429 ActiveX component can't create object.
    I have no idea why. Please help

    Below is the code I use:
    Code:
     
              Dim patha As String
              Dim result As Integer
              Dim displaymessage As Boolean
              Dim objOutlook As Outlook.Application
              Dim objOutlookMsg As Outlook.MailItem
              Dim objOutlookRecip As Outlook.Recipient
              Dim objOutlookAttach As Outlook.Attachment
              patha = "C:\temp\HATA814147586L02LA16010002160301.xml"
              displaymessage = True
              ' 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.
                  Temp = "xxxx@xxxxx.nl"
                  Set objOutlookRecip = .Recipients.Add(Temp)
                  objOutlookRecip.Type = olTo
    
    '              ' Add the CC recipient(s) to the message.
    '              Set objOutlookRecip = .Recipients.Add("me@...")
    '              objOutlookRecip.Type = olCC
    
                 ' Add the BCC recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("aaaaaa@aaaaaaaa.nl")
                  objOutlookRecip.Type = olBCC
    
                 ' Set the Subject, Body, and Importance of the message.
                 .Subject = "Hierbij zenden wij de gegevens"
                 .Body = "This is the body of the message." & vbCrLf & vbCrLf
                 .Importance = olImportanceHigh  'High importance
    
                 ' Add attachments to the message.
                 'If Not IsMissing(AttachmentPath) Then
                     Set objOutlookAttach = .Attachments.Add(patha)
                 'End If
    
                 ' Resolve each Recipient's name.
                 For Each objOutlookRecip In .Recipients
                     objOutlookRecip.Resolve
                 Next
    
                 ' Should we display the message before sending?
                 If displaymessage Then
                     .Display
                 Else
                     .Save
                     .Send
                 End If
              End With
              Set objOutlook = Nothing
        End Select
    ..

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Problem with Outlook

    Is the correct version of Outlook installed on the machine where you are trying to create the object?

  3. #3
    Join Date
    Feb 2003
    Location
    Holland
    Posts
    146

    Re: Problem with Outlook

    I am using outlook 2013

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Problem with Outlook

    Quote Originally Posted by HermanTabbert View Post
    I am using outlook 2013
    Ok. From my earlier question... Is the correct version of Outlook installed on the machine where you are trying to create the object? Have you upgraded Outlook since it quit working or have you used Outlook 2013 all along?

  5. #5
    Join Date
    Feb 2003
    Location
    Holland
    Posts
    146

    Re: Problem with Outlook

    Arjay,
    AS far as I know I have the correct version. Further, it is not only on my computer but also on the computers from my clients.
    I think perhaps it has to do with an update from Microsoft.

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Problem with Outlook

    This did work a long time good.
    Since about two month I get the error 429 ActiveX component can't create object

    I think perhaps it has to do with an update from Microsoft.
    What version of Windows is being used?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7
    Join Date
    Feb 2003
    Location
    Holland
    Posts
    146

    Re: Problem with Outlook

    Windows 10

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Problem with Outlook

    Quote Originally Posted by HermanTabbert View Post
    Arjay,
    AS far as I know I have the correct version. Further, it is not only on my computer but also on the computers from my clients.
    I think perhaps it has to do with an update from Microsoft.
    There can be many variables that will cause something to quit working. It could be a Microsoft update or may be something else entirely like a change in Outlook's configuration, or some other client software. Even a permissions change may cause the error. Hopefully, your software logs error to a file or the event viewer where you can have your client send you the logs/errors. If not, perhaps you can send them and instrumented version of your software that does log so you can get more detailed error info.

  9. #9
    Join Date
    Apr 2017
    Posts
    3

    Re: Problem with Outlook

    This code works fine for me:

    Code:
        Dim olapp As Object
        Dim oitem As Object
        Txto$ = "Body Message you want to send"
        Set olapp = CreateObject("Outlook.Application.15") '·········· > For new office versions
        Set oitem = olapp.CreateItem(0) '·································· >
    
        With oitem '··············································· > With created object
            .Subject = "Resumen de Ingresos del " & Date '········· >  EMail Subject
            .To = "emailone@gmail.com" '··············· > Email account
            .CC = "emailtwo@hotmail.com"  '··················· > With copy
            .Body = Txto$ '········································ > Mail content
            .Attachments ("drive:\path\filename.extsn") '··················· >
            .Send '················································ > Sends EMail
        End With '······································· >
        Set olapp = Nothing
        Set oitem = Nothing
    I hope this helps

    PS no need to add a reference, you just have to have MSOffice installed. It may take a few seconds to deliver the MSG to outlook, depending on the PC you are using.
    Last edited by 2kaud; April 9th, 2017 at 01:02 PM. Reason: Added code tags

  10. #10
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Problem with Outlook

    [When posting code, please use code tags rather than a different font. Go Advanced, select the formatted code and click '#'.]

    Cheers!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured