Beny at work



I need to create a function which send a mail. But when I execute my sub, I have a message warning. How can I send mail without this message

I need to send a mail to a user of my network, I use Exchange server.

thanks !



' Create an Outlook application.

Dim oApp As Outlook._Application

oApp = New Outlook.Application()

' Create a new MailItem.

Dim oMsg As Outlook._MailItem

oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)

oMsg.Subject = "Send Attachment Using OOM in Visual Basic .NET"

oMsg.Body = "Hello World" & vbCr & vbCr

' TODO: Replace with a valid e-mail address.

oMsg.To = ""

' Add an attachment

' TODO: Replace with a valid attachment path.

Dim sSource As String = "C:\Temp\Hello.txt"

' TODO: Replace with attachment name

Dim sDisplayName As String = "Hello.txt"

Dim sBodyLen As String = oMsg.Body.Length

Dim oAttachs As Outlook.Attachments = oMsg.Attachments

Dim oAttach As Outlook.Attachment

oAttach = oAttachs.Add(sSource, , sBodyLen + 1, sDisplayName)

' Send


' Clean up

oApp = Nothing

oMsg = Nothing

oAttach = Nothing

oAttachs = Nothing


Re: Visual Basic General Outlook - Send mail without a message warning


It is a built in security feature of outlook....instead of using the outlook application to send email...use the namespace to send the mail

Re: Visual Basic General Outlook - Send mail without a message warning


Here's how i do it, i don't get any popups though. Seems to be almost the same code.

Referenced is 'Microsoft Outlook 11.0 Object Library' (Microsoft.Office.Interop.Outlook.dll)

Imports Microsoft.Office.Interop.Outlook

Dim OO As Outlook.Application

Dim oMsg As Outlook._MailItem

If OO Is Nothing Then OO = New Outlook.Application

oMsg = OO.CreateItem(Outlook.OlItemType.olMailItem)

oMsg.Subject = "subjectˇ±

oMsg.Body = ˇ°bodyˇ±


oMsg.To = ˇ°to@to.comˇ±


oMsg = Nothing

OO = Nothing