Hi,
Trying to learn .net and facing an issue when calling the following proc if MSOutlook is not installed on the users machine (we have some liteclient PCs that don't) Hopefully this is a simple one that you experts can point me in the right direction of but the error is trying to load the interop even though i'm using Try... Catch...
Help!! (Edit: I should add that if MSOutlook is not installed then just getting the message that the user cannot send email is fine - I don't want them to ba able to)
Trying to learn .net and facing an issue when calling the following proc if MSOutlook is not installed on the users machine (we have some liteclient PCs that don't) Hopefully this is a simple one that you experts can point me in the right direction of but the error is trying to load the interop even though i'm using Try... Catch...
Help!! (Edit: I should add that if MSOutlook is not installed then just getting the message that the user cannot send email is fine - I don't want them to ba able to)
VB.NET:
Imports Microsoft.Office.Interop
Sub SendEmail(ByVal eSub$, ByVal Att$)
Try
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim fdMail As Outlook.MAPIFolder
Dim newMail As Outlook.MailItem
'----------------------------------
ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)
fdMail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)
newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
With newMail
.Subject = eSub
.Body = "Please note that the attached document..."
.Attachments.Add(Att)
.SaveSentMessageFolder = fdMail
.Display()
End With
Catch ex As Exception
MsgBox("Unable to email", 48, c_AppName)
End Try
End Sub
Last edited: