|
-
Jun 29th, 2006, 05:54 PM
#1
Thread Starter
Hyperactive Member
RE: Tracking if a message was sent with OL Reference
Hey all, im using a createobject reference (see below) to call an outlook mail message... I wanted to track if it is sent or not so that I can take the final composed message and store it in a database (This is for message tracking from within my application) See code below, any suggestions would be helpful! Thanks!
VB Code:
Dim olMailItem
Dim olApp As Object
Dim objMail As Object
Set olApp = CreateObject("Outlook.Application")
Set objMail = olApp.CreateItem(olMailItem)
Set objMail = olApp.CreateItem(olMailItem)
With objMail
If (strRecipientName <> "") And (IsNull(strRecipientName) = False) Then .To = strRecipientName
.HTMLBody = strMailTemplateInfo
.Subject = "Critical Call IM" & KillZeros(Mid(frmMain.lblTickInfo.Caption, 3, 13)) & " - " & strMsgSubType & " - " & frmMain.txtKnownApps
On Error GoTo DialogOpen
.Display
End With
"I dont even see the code anymore... I just see Blonde, Brunette, Redhead..."
-
Jun 29th, 2006, 07:56 PM
#2
Re: Tracking if a message was sent with OL Reference
Well you have created two instances of the email item object variable and only need one.
You mean to determine if the user clicked send after the .Display line?
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 
-
Jun 29th, 2006, 09:59 PM
#3
Thread Starter
Hyperactive Member
Re: Tracking if a message was sent with OL Reference
your right, I totally did, well the first dim isnt even really used so I can remove that from my code.. But yes that is exactly what I want to do.... basically if the user closes the message, I want it to return to the app saying that the message was closed and not sent... but if they send, I want to capture the body, subject, and sent information before it goes out... The message is sent from a shared mailbox, so I cannot have the application go to the sent items folder and retrieve it... nor would I really want to, I would like to keep all activity as localized as possible
Thanks!
"I dont even see the code anymore... I just see Blonde, Brunette, Redhead..."
-
Jun 29th, 2006, 10:40 PM
#4
Re: Tracking if a message was sent with OL Reference
Ok, as long as you can place this macro code behind users Outlook VBA class you can track all outgoing email.
VB Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Write out to a log or save info to a file etc.
End Sub
If not then you can show the message Modally and test for the email object variable still being instanciated. If its not then they closed the inspector window.
VB Code:
.Display vbModal
If TypeName(objMail) = "Nothing" Then
MsgBox "Forgot to send email before closing"
End If
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 
-
Jun 30th, 2006, 10:18 AM
#5
Thread Starter
Hyperactive Member
Re: Tracking if a message was sent with OL Reference
I would actually like to stay away from putting VBA in outlook, I want all coding to be completely on my application side
is there a way that I can get the message contents out of it when it gets sent?
"I dont even see the code anymore... I just see Blonde, Brunette, Redhead..."
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
|