Late binding help,pls

Asghaar

Registered User.
Local time
Today, 12:42
Joined
Jul 4, 2012
Messages
47
Hello all,

I really need your help to convert this script that i put together and tested (works ok),but in late binding since the users have different versions of Outlook and right now it works only with outlook reference activated.

The code does a simple thing - takes the current opened e-mail and allows the user to add other e-mail address to the .To and .CC ( actually it adds a recordset build separately by the user,but for this situation the code is with some general examples ).

Keeping things short,if i disable outlook reference i get a compile error for
Code:
 Dim myEmail As Inspector
.

All the help will be greatly appreciated.


Code:
Private Sub Toggle1_Click()

Dim myEmail As Inspector
Dim SaveEmail As Object
Dim strName As String
'Search for open mail
Set myEmail = Outlook.Application.ActiveInspector
If Not TypeName(myEmail) = "Nothing" Then
Set SaveEmail = myEmail.currentItem
Else
MsgBox "No open mail has been detected" & Chr(13) & _
"If you wish to add an email, you will have " & Chr(13) & _
"to open the mail.", vbOKOnly, "No open mail detected"
End If

With SaveEmail

' this keeps the existing address and adds with the command below something else
        string1 = .To 
        .To = string1 & " ; " & "whatever"
        .CC = "something"
       
       
        .Display
       
End With
 
End Sub
 
<Untested>

Dim myEmail As Object
Dim objOutlook as object

Set objOutlook = CreateObject("Outlook.Application")
Set myEmail = objOutlook.ActiveInspector
.... Your code

</Untested>

I think the above will do it for ya. Do not forget to destroy all of the objects you created by setting thme to nothing when you are done.

Rdub
 
Hello rdub,

Worked great.
Thank you very much for the help - maybe soon i"ll have a better grasp on late binding and be able to figure out alone this types os simple questions.

Here is the code for anyone interested:

Code:
Dim myEmail As Object
Dim objOutlook As Object
Dim SaveEmail As Object

Set objOutlook = CreateObject("Outlook.Application")
Set myEmail = objOutlook.ActiveInspector


If Not TypeName(myEmail) = "Nothing" Then
Set SaveEmail = myEmail.currentItem
'SaveEmail.SaveAs "E:\Marius_Avornicesei\default.txt", olMSG
Else
MsgBox "No open mail has been detected" & Chr(13) & _
"If you wish to add an email, you will have " & Chr(13) & _
"to open the mail.", vbOKOnly, "No open mail detected"
End If

With SaveEmail
         string1 = .To
        .To = string1 & " ; " & "whatever"
        .CC = "something"
        .Display       
End With

Once again thank you rdub.
 

Users who are viewing this thread

Back
Top Bottom