|
-
May 24th, 2006, 11:03 PM
#1
Thread Starter
New Member
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:
Private Sub DoMailingMSOutlook()
Dim objOutlook As Object
Dim objOutlookMsg As Object
'late binding method
Set objOutlook = CreateObject("Outlook.Application")
' we use zero argument as it is for new mail message
'Appointment 1; 'Contact 2; 'Distribution List 7
'Journal 4; 'Mail Message 0; 'Note 5 'Post 6; 'Task 3
Set objOutlookMsg = objOutlook.CreateItem(0)
strSubject = "MF " & strPortfolio
With objOutlookMsg
.Subject = strSubject
If FilDat = "" Then
MsgBox "No body text for '" & strPortfolio & "'", vbInformation, g_strPackage
Else
MsgBox "There is body text for '" & strPortfolio & "'", vbInformation, g_strPackage
MsgBox "Body text is: '" & FilDat & "'", vbInformation, g_strPackage
.Body = FilDat
.Attachments.Add FilName
.display
End If
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
6. Any suggestions on code ? And why the dafault mail account is not geting pircked up ?
Rgds
-
May 25th, 2006, 03:05 AM
#2
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:
'...
objOutlookMsg.BodyFormat = 1 'olFormatPlain
objOutlookMsg.Body = "Meow.NET!"
'...
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
May 25th, 2006, 09:53 AM
#3
Thread Starter
New Member
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.
-
May 25th, 2006, 04:25 PM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
May 25th, 2006, 09:33 PM
#5
Thread Starter
New Member
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.
-
May 26th, 2006, 02:22 PM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
May 29th, 2006, 05:03 AM
#7
Thread Starter
New Member
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.
-
May 29th, 2006, 12:39 PM
#8
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|