Hi,
The following code used to work, but since upgrading to Win7 it no longer does (security issues??). We use this code to send an outlook e-mail through another application.
Private Sub SendOutlookEmail(ByVal txtSubject As String, ByVal txtBody As String) Dim ol As New Outlook.Application() Dim ns As Outlook.NameSpace Dim mail As Outlook.MAPIFolder ns = ol.GetNamespace("MAPI") ns.Logon(, , True, True) Dim newMail As Outlook.MailItem mail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox) newMail = mail.Items.Add(Outlook.OlItemType.olMailItem) newMail.Subject = txtSubject newMail.Body = txtBody newMail.To = "*****" newMail.CC = "*****" newMail.SaveSentMessageFolder = mail newMail.Send() End Sub
If Outlook is closed, it works ok, but then the user has to right click on the icon in the bottom right 'hidden icons' to exit Outlook manually. If outlook is already open, an error message occurs. I'm certain it's the Dim ol As New Outlook.Application() that is the problem, but I'm not sure how to get around it.
Thanks,
Brian