Results 1 to 8 of 8

Thread: Erratic behaviour in Email sending by Outlook Object in VB6

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Location
    New Delhi, India
    Posts
    4

    Question Erratic behaviour in Email sending by Outlook Object in VB6

    I am sending emails thru Outlook object in VB6. At one stage it was sending the mails properly.
    Suddenly 2 things have started happening in Outlook:

    1. The default mail sending account is not geting used anymore. It shows blank there. I have set

    the default settings as plain text and not to send immdly.

    2. .Body of the mailitem shows its matter properly when i debug and check thru .display. But

    finally when .send is executed and I see the email in Outlook outbox, it has no text in body.

    I have checked that the Fildata variable which contains body text contains proper values. I am

    showing the values thru messagebox and display as well. It displays properly, but once in Outlook

    outbox, email body matter vanishes.

    And very rarely, once in a while the body contents also stay and do not vanish. Its quite

    erratic.

    But sender details are always blank, even after having a valid default email account.

    If somehow I attach a file using .Attachments.Add, that attachment stays properly.

    3. I am using VB6, with Win Xp - pro.

    4. I have even tried disabling firewall and scanning for virus etc.

    5. Here's the part of the code:

    VB Code:
    1. Private Sub DoMailingMSOutlook()
    2.  
    3.     Dim objOutlook As Object
    4.     Dim objOutlookMsg As Object
    5.    
    6.     'late binding method
    7.     Set objOutlook = CreateObject("Outlook.Application")
    8.        
    9.     ' we use zero argument as it is for new mail message
    10.     'Appointment  1;     'Contact 2;    'Distribution List 7
    11.     'Journal 4;     'Mail Message 0;     'Note 5    'Post 6;     'Task 3
    12.  
    13.     Set objOutlookMsg = objOutlook.CreateItem(0)
    14.     strSubject = "MF " & strPortfolio
    15.    
    16.     With objOutlookMsg
    17.          
    18.         .To = "[email protected]"
    19.         .Subject = strSubject
    20.         If FilDat = "" Then
    21.            MsgBox "No body text for '" & strPortfolio & "'", vbInformation, g_strPackage
    22.         Else
    23.             MsgBox "There is body text for '" & strPortfolio & "'", vbInformation, g_strPackage
    24.             MsgBox "Body text is: '" & FilDat & "'", vbInformation, g_strPackage
    25.            
    26.             .Body = FilDat
    27.             .Attachments.Add FilName
    28.            
    29.             .display
    30.         End If
    31.        
    32.         .Send
    33.     End With
    34.     Set objOutlookMsg = Nothing
    35.     Set objOutlook = Nothing
    36. End Sub

    6. Any suggestions on code ? And why the dafault mail account is not geting pircked up ?

    Rgds

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Erratic behaviour in Email sending by Outlook Object in VB6

    Welcome to the Forums.

    I see that your .Display the message and then after your doing a .Send. It may help if you display the message modally in case anything the user is doing while displayed is causing the irregularities.

    Also, your not spoecifing the BodyFormat type.

    What version of Outlook?


    VB Code:
    1. '...
    2.  
    3. objOutlookMsg.BodyFormat = 1 'olFormatPlain
    4. objOutlookMsg.Body = "Meow.NET!"
    5.  
    6. '...
    7. objOutlookMsg.Display vbModal
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2006
    Location
    New Delhi, India
    Posts
    4

    Re: Erratic behaviour in Email sending by Outlook Object in VB6

    Hi, and thanx.

    I am using Outlook 2002. The default body format I have taken is plain text, and from ver Outlook ver 2002 .body picks up the default text format properly. I have also checked that plain text format is getting selected correctly.

    The .display as well as messageboxes have been used mainly for debugging, I dont need them in my program.

    I have made .display vbModal as per your suggestion.

    I have even tried some hard-coded text rather than picking up value from a variable for .body. When the mailitem gets displayed, body text is shown properly, but once Outlook security question comes at .send, the email lands up in outbox with missing body text.

    One important point I missed - I am iterating thru a loop and picking up one of the portfolios for a user, and in each email message sending the portfolio details as body text. So its being run not once, but a few times, for all the portfolios of the user. I have also moved the variable declarations for outlook objects appropriately, away from this routine. I am also killing off the variables properly while exiting.

    The problem persists.

    Best Regards
    Last edited by mpsahuja; May 25th, 2006 at 10:07 AM.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Erratic behaviour in Email sending by Outlook Object in VB6

    If you dont specify the bodyformat then its open to intreptation and potential issues.

    objOutlookMsg.BodyFormat = 1

    If your doing this in a loop then you dont need to be creating the Outlook.Application object for each iteration. Just create it once before the call to the loop and then destroy after the loop is done.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2006
    Location
    New Delhi, India
    Posts
    4

    Re: Erratic behaviour in Email sending by Outlook Object in VB6

    already done these two things:

    objOutlookMsg.BodyFormat = 1

    &

    If your doing this in a loop then you dont need to be creating the Outlook.Application object for each iteration. Just create it once before the call to the loop and then destroy after the loop is done.


    Still the problem is there.

    I cudnt come across this sort of problem in knowledgebase. The thing is, this program was behaving earlier.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Erratic behaviour in Email sending by Outlook Object in VB6

    Maybe you did a recent windows or Office update?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2006
    Location
    New Delhi, India
    Posts
    4

    Question Re: Erratic behaviour in Email sending by Outlook Object in VB6

    Hi, I appreciate your help all thru.

    Well, I had unchecked the immediate sending option, in Outlook 2002. So with some emails in outbox with showing no body text, I decided to click send button on Outlook, and found that the emails reached destinations with all proper text in it ! So the problem is only in my outlook setup which is not showing emails properly. I cudnt figure out how to correct this in Outlook.

    Now, the clients have Outlook 2000 (under xp pro), running in a different city, some 1500 kms away, so i havent seen complete system myself. In mailing module they are getting Error 429, Active X component cannot create object, pointing to Outlook. Can you guide here, as this error also needs elimination of various aspects, as per Microsoft knowledge base articlea I scanned thru. Their registery is fine, and they have run patch also, same problem persists.

    Best Regards
    Last edited by mpsahuja; May 29th, 2006 at 09:47 AM.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Erratic behaviour in Email sending by Outlook Object in VB6

    The 429 error is because the VBAProject has a default reference set to Outlook 11.0 Now if you distribute it you may have to remove the 11.0 reference and add a reference to Outlook xx.0 that they have.

    Also, could be any other reference you have added like ADO 2.x if your connecting to a database, etc.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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