473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Outlook object question in VB.NET

I am using VB.NET 2008 and in the COM Tab I add a reference to "Microsoft
Outlook 11.0 Object Library".
When I send an email, a window with the following message (and buttons Yes,
No, Help) always pops up on the screen:
"A program is trying to automatically send e-mail on your behalf. Do you
want to allow this ?
If this is unexpected, it may be a virus and you should choose "No"."

Why does that window pop up, and how can I make it not popup ?
Thank you very much.
Main program
Private oMail As New OutlookMail

sub myForm_Load(...)
oMail.startOutlook()
end sub

Private Sub myForm_FormClosing(..)
oMail = Nothing
End Sub

Sub SendEmail(ByVal sMsg As String, ByVal sToEmail As String, ByVal sSubject
As String)
Dim swError As StreamWriter

If sToEmail <"" Then
oMail.SendEmail(sToEmail, sSubject, sMsg)
End If

End Sub

Private Sub cmdEmail_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEmail.Click
SendEmail(txtLog.Text, txtEmails.Text, "my subject")
End Sub

Imports Outlook = Microsoft.Office.Interop.Outlook
Imports System
Public Class OutlookMail
Dim ns As Outlook.NameSpace
Public Function startOutlook()
'Return a reference to the MAPI layer
Dim ol As New Outlook.Application()

ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)
End Function
Public Sub SendEmail(ByVal toVal As String, ByVal subjectVal As String,
ByVal bodyVal As String) ', ByVal sMailID As String)
Dim newMail As Outlook.MailItem
Dim fdMail As Outlook.MAPIFolder

fdMail =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFol derOutbox)

'assign values to the newMail MailItem
newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = subjectVal
newMail.Body = bodyVal
newMail.To = toVal
newMail.SaveSentMessageFolder = fdMail
newMail.Send()
End Sub
End Class
Jun 27 '08 #1
4 2000
Because you are accessing a mail client (Outlook), you will get Outlook's
built-in security. It comes up to prevent someone from writing a spam virus
that sends out gobs of email without the user knowing it.

I don't believe you can get around this since it is a security feature.
But, if you were to send mail (via code) directly from an SMTP server (like
MS Exchange) you wouldn't get that message.

-Scott

"fniles" <fn****@pfmail.comwrote in message
news:uu****************@TK2MSFTNGP03.phx.gbl...
>I am using VB.NET 2008 and in the COM Tab I add a reference to "Microsoft
Outlook 11.0 Object Library".
When I send an email, a window with the following message (and buttons
Yes, No, Help) always pops up on the screen:
"A program is trying to automatically send e-mail on your behalf. Do you
want to allow this ?
If this is unexpected, it may be a virus and you should choose "No"."

Why does that window pop up, and how can I make it not popup ?
Thank you very much.
Main program
Private oMail As New OutlookMail

sub myForm_Load(...)
oMail.startOutlook()
end sub

Private Sub myForm_FormClosing(..)
oMail = Nothing
End Sub

Sub SendEmail(ByVal sMsg As String, ByVal sToEmail As String, ByVal
sSubject As String)
Dim swError As StreamWriter

If sToEmail <"" Then
oMail.SendEmail(sToEmail, sSubject, sMsg)
End If

End Sub

Private Sub cmdEmail_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEmail.Click
SendEmail(txtLog.Text, txtEmails.Text, "my subject")
End Sub

Imports Outlook = Microsoft.Office.Interop.Outlook
Imports System
Public Class OutlookMail
Dim ns As Outlook.NameSpace
Public Function startOutlook()
'Return a reference to the MAPI layer
Dim ol As New Outlook.Application()

ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)
End Function
Public Sub SendEmail(ByVal toVal As String, ByVal subjectVal As String,
ByVal bodyVal As String) ', ByVal sMailID As String)
Dim newMail As Outlook.MailItem
Dim fdMail As Outlook.MAPIFolder

fdMail =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFol derOutbox)

'assign values to the newMail MailItem
newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = subjectVal
newMail.Body = bodyVal
newMail.To = toVal
newMail.SaveSentMessageFolder = fdMail
newMail.Send()
End Sub
End Class

Jun 27 '08 #2
Thank you for your reply.
The reason why I use Outlook is because with Outlook I can easily see all
the mails I sent in the "Sent" folder, but I can't do that easily with SMTP.
"Scott M." <sm**@nospam.nospamwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
Because you are accessing a mail client (Outlook), you will get Outlook's
built-in security. It comes up to prevent someone from writing a spam
virus that sends out gobs of email without the user knowing it.

I don't believe you can get around this since it is a security feature.
But, if you were to send mail (via code) directly from an SMTP server
(like MS Exchange) you wouldn't get that message.

-Scott

"fniles" <fn****@pfmail.comwrote in message
news:uu****************@TK2MSFTNGP03.phx.gbl...
>>I am using VB.NET 2008 and in the COM Tab I add a reference to "Microsoft
Outlook 11.0 Object Library".
When I send an email, a window with the following message (and buttons
Yes, No, Help) always pops up on the screen:
"A program is trying to automatically send e-mail on your behalf. Do you
want to allow this ?
If this is unexpected, it may be a virus and you should choose "No"."

Why does that window pop up, and how can I make it not popup ?
Thank you very much.
Main program
Private oMail As New OutlookMail

sub myForm_Load(...)
oMail.startOutlook()
end sub

Private Sub myForm_FormClosing(..)
oMail = Nothing
End Sub

Sub SendEmail(ByVal sMsg As String, ByVal sToEmail As String, ByVal
sSubject As String)
Dim swError As StreamWriter

If sToEmail <"" Then
oMail.SendEmail(sToEmail, sSubject, sMsg)
End If

End Sub

Private Sub cmdEmail_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEmail.Click
SendEmail(txtLog.Text, txtEmails.Text, "my subject")
End Sub

Imports Outlook = Microsoft.Office.Interop.Outlook
Imports System
Public Class OutlookMail
Dim ns As Outlook.NameSpace
Public Function startOutlook()
'Return a reference to the MAPI layer
Dim ol As New Outlook.Application()

ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)
End Function
Public Sub SendEmail(ByVal toVal As String, ByVal subjectVal As
String, ByVal bodyVal As String) ', ByVal sMailID As String)
Dim newMail As Outlook.MailItem
Dim fdMail As Outlook.MAPIFolder

fdMail =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderOutbox)

'assign values to the newMail MailItem
newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = subjectVal
newMail.Body = bodyVal
newMail.To = toVal
newMail.SaveSentMessageFolder = fdMail
newMail.Send()
End Sub
End Class


Jun 27 '08 #3
When sending mail from a server, you must look at the server logs to see
what's been sent.
"fniles" <fn****@pfmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Thank you for your reply.
The reason why I use Outlook is because with Outlook I can easily see all
the mails I sent in the "Sent" folder, but I can't do that easily with
SMTP.
"Scott M." <sm**@nospam.nospamwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>Because you are accessing a mail client (Outlook), you will get Outlook's
built-in security. It comes up to prevent someone from writing a spam
virus that sends out gobs of email without the user knowing it.

I don't believe you can get around this since it is a security feature.
But, if you were to send mail (via code) directly from an SMTP server
(like MS Exchange) you wouldn't get that message.

-Scott

"fniles" <fn****@pfmail.comwrote in message
news:uu****************@TK2MSFTNGP03.phx.gbl...
>>>I am using VB.NET 2008 and in the COM Tab I add a reference to "Microsoft
Outlook 11.0 Object Library".
When I send an email, a window with the following message (and buttons
Yes, No, Help) always pops up on the screen:
"A program is trying to automatically send e-mail on your behalf. Do you
want to allow this ?
If this is unexpected, it may be a virus and you should choose "No"."

Why does that window pop up, and how can I make it not popup ?
Thank you very much.
Main program
Private oMail As New OutlookMail

sub myForm_Load(...)
oMail.startOutlook()
end sub

Private Sub myForm_FormClosing(..)
oMail = Nothing
End Sub

Sub SendEmail(ByVal sMsg As String, ByVal sToEmail As String, ByVal
sSubject As String)
Dim swError As StreamWriter

If sToEmail <"" Then
oMail.SendEmail(sToEmail, sSubject, sMsg)
End If

End Sub

Private Sub cmdEmail_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEmail.Click
SendEmail(txtLog.Text, txtEmails.Text, "my subject")
End Sub

Imports Outlook = Microsoft.Office.Interop.Outlook
Imports System
Public Class OutlookMail
Dim ns As Outlook.NameSpace
Public Function startOutlook()
'Return a reference to the MAPI layer
Dim ol As New Outlook.Application()

ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)
End Function
Public Sub SendEmail(ByVal toVal As String, ByVal subjectVal As
String, ByVal bodyVal As String) ', ByVal sMailID As String)
Dim newMail As Outlook.MailItem
Dim fdMail As Outlook.MAPIFolder

fdMail =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderOutbox)

'assign values to the newMail MailItem
newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = subjectVal
newMail.Body = bodyVal
newMail.To = toVal
newMail.SaveSentMessageFolder = fdMail
newMail.Send()
End Sub
End Class



Jun 27 '08 #4
"fniles" <fn****@pfmail.com>'s wild thoughts were released
on Tue, 10 Jun 2008 14:48:48 -0500 bearing the following
fruit:
>I am using VB.NET 2008 and in the COM Tab I add a reference to "Microsoft
Outlook 11.0 Object Library".
When I send an email, a window with the following message (and buttons Yes,
No, Help) always pops up on the screen:
"A program is trying to automatically send e-mail on your behalf. Do you
want to allow this ?
If this is unexpected, it may be a virus and you should choose "No"."

Why does that window pop up, and how can I make it not popup ?
There are lots of products out there, some free that disable
the security prompt - try mapilab.

J
>Thank you very much.
Main program
Private oMail As New OutlookMail

sub myForm_Load(...)
oMail.startOutlook()
end sub

Private Sub myForm_FormClosing(..)
oMail = Nothing
End Sub

Sub SendEmail(ByVal sMsg As String, ByVal sToEmail As String, ByVal sSubject
As String)
Dim swError As StreamWriter

If sToEmail <"" Then
oMail.SendEmail(sToEmail, sSubject, sMsg)
End If

End Sub

Private Sub cmdEmail_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEmail.Click
SendEmail(txtLog.Text, txtEmails.Text, "my subject")
End Sub

Imports Outlook = Microsoft.Office.Interop.Outlook
Imports System
Public Class OutlookMail
Dim ns As Outlook.NameSpace
Public Function startOutlook()
'Return a reference to the MAPI layer
Dim ol As New Outlook.Application()

ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)
End Function
Public Sub SendEmail(ByVal toVal As String, ByVal subjectVal As String,
ByVal bodyVal As String) ', ByVal sMailID As String)
Dim newMail As Outlook.MailItem
Dim fdMail As Outlook.MAPIFolder

fdMail =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderOutbox)

'assign values to the newMail MailItem
newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = subjectVal
newMail.Body = bodyVal
newMail.To = toVal
newMail.SaveSentMessageFolder = fdMail
newMail.Send()
End Sub
End Class
--
Jan Hyde

https://mvp.support.microsoft.com/profile/Jan.Hyde
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John | last post by:
Hi When I open a new outlook email from vb.net, sometimes outlook is very slow to appear or occasionally outlook freezes completely. I am targeting mixed office2000/xp environments so I am...
2
by: John | last post by:
Hi I am trying to find the way to create an email in outlook. I am using the code given at the end. It works fine the first time but calling the code second time gives the following error; ...
9
by: Srinivas | last post by:
hi all how to access the outlook user profiles through VB.net any help.... thanks in advanc Srinivas
8
by: Li Pang | last post by:
Hi, I used following codes to pass a message item from CDO to Outlook. They worked fine when I used outlook 2000, but get an error of "Specified cast is not valid." when I used Outlook 2003....
3
by: wizzbangca | last post by:
Hi everyone. Having problems with a utility I am writing for work. The previous IT Director thoughtfully allowed 3 (2000, xp, 2003) versions of outlook to be installed rather than 1. Now I need...
4
by: Pieter | last post by:
Hi, On the pc of one of my clients (W2000, Office 2003) I'm getting sometimes an exception when moving (Move) a MailItem to an Outlook-Folder: The RPC server is not available. (Exception from...
2
by: Pieter | last post by:
Hi, I'm using a thight integration with Outlook 2003 (with an Exchange server) in my VB.NET (2005) application. Until now I'm using the Outlook Object Model, but it appears to be very slow, and...
7
by: Dean Spencer | last post by:
Can anyone help? I am importing Emails from Outlook using the following code: Public Function ScanInbox(SubjectLine As String) Dim TempRst As Recordset Dim OlApp As Outlook.Application Dim...
5
by: fniles | last post by:
I am using VB.NET 2005. I created a project using the Microsoft Outlook 8.0 Object Library (Object Model) in my previous machine. Now that I have a new machine, when I try to compile that program...
1
by: Sylfelin | last post by:
Hello, If I use Microsoft Outlook 12.0 Object Library (Outlook 2007) COM Object in my application, the custommer must have the outlook 2007 on his computer ? But if i use Microsoft Outlook...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.