473,419 Members | 1,698 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,419 software developers and data experts.

C# ASP.NEt calling Outlook Interop

Hi,

I am trying to send mail thru outlook. I have found some code on the web and
ws trying it out. I was successful in creating a mail in the draft folder of
outlook, however hangs for a long time during the sending of the mail.

Snippet code as below
-------------------------------------------

using Outlook = Microsoft.Office.Interop.Outlook; //using the 11.0 object
library

private Outlook.Application oApp = null;
private Outlook.NameSpace oNameSpace = null;
private Outlook.MAPIFolder oOutboxFolder = null;

oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,true,true);
oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolde rs.olFolderOutbox);

Outlook.MailItemClass mi =
(Outlook.MailItemClass)oApp.CreateItem(Outlook.OlI temType.olMailItem);
mi.To = "te**@test.com";
mi.Body = "Some Message";
mi.Subject = "Some Title";
mi.SaveSentMessageFolder = oOutboxFolder;
mi.Save(); //works where i am able to see the mail in the draft folder
mi.Send(); //does not execute where the web page just stalls

-------------------------------------------------

Any help why this is happening, if the save() works, why does the send just
stalls and does not drop a mail in the outbox for sending.

Is there any settings on the server side which i miss?

I am running everything below on the same pc :-
Windows Server 2003 Enteprise Ed
..NET 1.1 Framework
MS IIS 6
MS Exchange 2003
Office 2003(Outlook 2003 and etc)

Thanks,

Joey
Nov 19 '05 #1
1 4873
Just a guess, but when using the Outlook Interop in this way you must give it
explicit commands. It's possible that you're sending the mail item to the
outbox with send, but not performing a send/receive.

Any reason you didn't just use the SMTP class???

Ryan

"Joey Lee" wrote:
Hi,

I am trying to send mail thru outlook. I have found some code on the web and
ws trying it out. I was successful in creating a mail in the draft folder of
outlook, however hangs for a long time during the sending of the mail.

Snippet code as below
-------------------------------------------

using Outlook = Microsoft.Office.Interop.Outlook; //using the 11.0 object
library

private Outlook.Application oApp = null;
private Outlook.NameSpace oNameSpace = null;
private Outlook.MAPIFolder oOutboxFolder = null;

oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,true,true);
oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolde rs.olFolderOutbox);

Outlook.MailItemClass mi =
(Outlook.MailItemClass)oApp.CreateItem(Outlook.OlI temType.olMailItem);
mi.To = "te**@test.com";
mi.Body = "Some Message";
mi.Subject = "Some Title";
mi.SaveSentMessageFolder = oOutboxFolder;
mi.Save(); //works where i am able to see the mail in the draft folder
mi.Send(); //does not execute where the web page just stalls

-------------------------------------------------

Any help why this is happening, if the save() works, why does the send just
stalls and does not drop a mail in the outbox for sending.

Is there any settings on the server side which i miss?

I am running everything below on the same pc :-
Windows Server 2003 Enteprise Ed
..NET 1.1 Framework
MS IIS 6
MS Exchange 2003
Office 2003(Outlook 2003 and etc)

Thanks,

Joey

Nov 19 '05 #2

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

Similar topics

12
by: guy lateur | last post by:
Hi all, I am trying to write some code (macro's, if you like) to glue together our Office applications (mainly Word, Excel and Outlook). We have a lot of different projects going on...
0
by: W Akthar | last post by:
Hi All, I have created a simple Windows Service which needs to be able to send appointments to Outlook. I have no problem makeing a reference to Microsoft Outlook 11.0 Object Library and...
4
by: John | last post by:
Hi Does anyone have a vb.net example of how to use redemption to send mail through outlook? Many Thanks Regards
9
by: Srinivas | last post by:
hi all how to access the outlook user profiles through VB.net any help.... thanks in advanc Srinivas
4
by: Brett | last post by:
When I run this line: myolApp = CreateObject("Outlook.Application") The myolApp object has a value of {Outlook.ApplicationClass}. When I expand it in the watch window, all properties/methods...
2
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a...
3
by: mwolowski | last post by:
Hello, I'd like to add tasks, appointments, etc using c# to outlook For example i added reference using OutLook = Microsoft.Office.Interop.Outlook; and the code: 1. ---------------------...
1
by: =?Utf-8?B?cm9i?= | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
1
by: allbelonging | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.