VB.NET - Email code does not work with Office 365
SuperCoder
136
Reputation points
The code below has been used successfully for awhile, but we recently discovered that it is not compatible with Office 365. We need to modify the code but we don't know where to start (online searches were not helpful). Could someone please point us to where we can obtain information about this? Thank you.
Private Sub btnEmail_Click(sender As Object, e As EventArgs) Handles btnEmail.Click
Dim EmailAddress = GetEmailAdress("RF", FPMain.txtFAcct2.Text)
Dim Outlook As New Outlook.Application
Dim Mail As Outlook.MailItem
Dim Acc As Outlook.Account
Outlook = New Outlook.Application()
Mail = Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
Mail.To = EmailAddress
Mail.Subject = "Compliance Requirements"
For Each Acc In Outlook.Session.Accounts
'Select Case CaseCaseCasefirst pop3 For instance.
If Acc.AccountType = Microsoft.Office.Interop.Outlook.OlAccountType.olPop3 Then
Mail.Sender = Acc
End If
Next
'Attach files
Dim AttachmentDoc = GetDocPath() & "temp\" & FPMain.txtFAcct2.Text & ".pdf"
Mail.Attachments.Add(AttachmentDoc)
' Code below over writes the signiture
'Dim Body = "Please complete these compliance items or a giant green troll will eat you."
'Mail.HTMLBody = Body
Mail.Display()
End Sub
Sign in to answer