Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAPI and Outlook in vb.net

Status
Not open for further replies.

Premalm

Programmer
Mar 20, 2002
164
US
Hi Guys,

I have using MAPI to send emails in vb.net. I have using the default profile (MS Exchange Settings). I have set showdialog=false but still I get some dialog boxes. Is it possible if we can not show this dialogbox ? here's the code

Dim oSession As New MAPI.Session
oSession.Logon("MS Exchange Settings", , False, True)
Dim oMessage As MAPI.Message
Dim oAttach As MAPI.Attachment
Dim oRecipient As MAPI.Recipient
oMessage = oSession.Outbox.Messages.Add
oRecipient = oMessage.Recipients.add
oRecipient.Name = "Some One"
oRecipient.Resolve()
oMessage.Subject = "List"
oAttach = oMessage.Attachments.Add
oAttach.Source = sPath
oAttach.ReadFromFile(sPath)
Try
oMessage.Send(True, False)
Catch ex As Exception
MsgBox(ex.Source)
End Try
oSession.Logoff()

The dialog box Outlook show is

A program is trying to access email addresses you have stored in Outlook. Do you want to allow this ?

A program is trying to send email on your behalf. Do you want to allow this ?

Is there any way so that Outlook doesn't show these dialog boxes ?

Any Ideas ?

Thanks
Premal
 
You'll have to Google this problem. I have heard of ways around this... but its like a Hack.

You could try using System.Web.Mail which is SMTP based and then you wouldnt have that problem.
 
A good way I found around this is a little freeware app called CLICKYES, which you can incorporate very easily into your .Net app.


Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
Hi Guys,

I am trying to use System.web.mail from vb.net console application and I am getting the following error:

An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll
Additional information: Could not access 'CDO.Message' object.
I have added a reference to system.web.

Is it possible to use System.web.mail from a vb.net application ?

Any Ideas? Any other method to send an email.

Thanks
Premal
 
My problem is SMTP Server (localhost) sends the email but it sits in the Queue folder.

So I see all my emails are in C:\Inetpub\mailroot\Queue

Any Ideas how can I resolve this ?

In the event viewer I get a message
Message delivery to the remote domain 'mydomain.com' failed for the following reason: Unable to bind to the destination server in DNS.

Any ideas ?

Thanks
Premal
 
Premalm,

probably the easiest fix to get the emails going is to put the address of their SMTP server in the 'Smart Host' field of the delivery tab / advanced screen

I have included a screen shot... hope it helps.

smtpfix.jpg
 
In order for CDOSYS to send e-mail or other messages from your application, you need to enlist the services of IIS with the SMTP Service installed. Both are available in Windows 2000/XP through the Control Panel -> Add/Remove Programs -> Add/Remove Windows Components option. The job of the STMP Service is to accept and deliver the messages, based on the configuration. The service can attempt to deliver the messages directly, or it can utilize a smart host to deliver the message instead. When a smart host is enlisted, all messages are forwarded to it for delivery. You need to have IIS and the SMTP service installed and configured.

The SMTP Service uses a directory structure to contain messages prior to delivery. The default directory is C:\Inetpub\mailroot. This folder contains a number of subdirectories such as Queue, Drop, and Badmail. If you are unable to configure your instance of the SMTP Service for delivery, you can find the message in a *.EML file in the C:\Inetpub\mailroot\Queue directory. This technique can be useful when creating messages offline.

Sending a Message
As previously mentioned, sending an e-mail is a relatively simple thing to do. The System.Web.Mail.MailMessage class represents the message to be sent. E-mail messages are constructed by using instances of this class. This class contains properties such as To, From, and Subject that allow you to control the message being sent. Attachments can be created through instances of the System.Web.Mail.MailAttachment and then added to the MailMessage through the Attachments collection of the MailMessage. The message is then delivered through the System.Web.Mail.SmtpMail class.



Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top