473,545 Members | 529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send email through mapi

I am using the following code for sending email through mapi in VS 2005
environment:

Public objSession As New MSMAPI.MAPISess ion
Public objMessage As New MSMAPI.MAPIMess ages

objSession.Down LoadMail = False
objSession.User Name = "MyUsername "
objSession.Pass word = "MyPassword "
objSession.Sign On()
objMessage.Sess ionID = objSession.Sess ionID
objMessage.Comp ose()

objMessage.Reci pAddress = txtTo.Text
objMessage.Text = txtBody.Text
objMessage.Subj ect = txtSubject.Text

objMessage.Send (True) 'ShowDialog
MsgBox("Message sent successfully!")
objSession.Sign Off()

I uninstalled Microsoft Outlook (comes along with msoffice), now my
default client is Outlook Express, I get this exception:

An unhandled exception of type
'System.Runtime .InteropService s.COMException' occurred in
mailclient.exe

Can anybody help me out ?

Regards,
Sentiboy

Sep 6 '06 #1
3 4673
Why use an installed client when you can use the DotNet infrustructure,
which has it all built in?

'xxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xx
'SMTP EMAIL NOTES
'As condensed from: http://www.systemwebmail.com/default.aspx
'1. Have a reference set to the System.Web.dll.
'2. Have "Imports System.Web.Mail " statement at the top of your code.
'3. SmtpMail.SmtpSe rver must allow relaying for FROM email address or your
IP address,
' or you must use dotNET 1.1 or higher to authenticate.
'SAMPLE SETTINGS
'Dim emlEmail As New System.Web.Mail .MailMessage()
' NOTE: all email addresses can be like: "my******** @my-domain.com" - OR -
Fully named like: """John Smith"" <my********@m y-domain.com>"
' Also, multiple email addresses can be sent separated by semi-colon
character.
'emlEmail.To = "my******** @my-domain.com"
'emlEmail.From = "my******** @my-domain.com"
'emlEmail.Cc = "my******** @my-domain.com" 'optional
'emlEmail.Bcc = "my******** @my-domain.com" 'optional
'emlEmail.Subje ct = "SUBJECT_HE RE"
'emlEmail.BodyF ormat = MailFormat.Html
'emlEmail.Body = "BODY OF THE MESSAGE HERE"
'emlEmail.Heade rs.Add("Reply-To", "my******** @my-domain.com")
'Attachments()
'Dim attachment As New System.Web.Mail .MailAttachment ("C:\Foo.xls ") 'create
the attachment
'emlEmail.Attac hments.Add(atta chment) 'add the attachment
'Authentication cannot be done using the .NET Framework 1.0. Must use 1.1 or
higher.
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e",
"1") 'basic authentication
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/sendusername",
"my_username_he re") 'set your username here
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/sendpassword",
"super_secr et") 'set your password here
'SmtpMail.SmtpS erver = "EMAIL_SERVER_D OMAIN" 'your real server goes here
'SmtpMail.Send( emlEmail)
'xxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xx

Please note that the above example is for DotNet 1.x
http://www.systemwebmail.com/

To see more information for 2.x, see http://www.systemnetmail.com/

I have found these two sites very useful.

HTH.

Cheers!

~ Duane Phillips.

<se******@gmail .comwrote in message
news:11******** **************@ d34g2000cwd.goo glegroups.com.. .
>I am using the following code for sending email through mapi in VS 2005
environment:

Public objSession As New MSMAPI.MAPISess ion
Public objMessage As New MSMAPI.MAPIMess ages

objSession.Down LoadMail = False
objSession.User Name = "MyUsername "
objSession.Pass word = "MyPassword "
objSession.Sign On()
objMessage.Sess ionID = objSession.Sess ionID
objMessage.Comp ose()

objMessage.Reci pAddress = txtTo.Text
objMessage.Text = txtBody.Text
objMessage.Subj ect = txtSubject.Text

objMessage.Send (True) 'ShowDialog
MsgBox("Message sent successfully!")
objSession.Sign Off()

I uninstalled Microsoft Outlook (comes along with msoffice), now my
default client is Outlook Express, I get this exception:

An unhandled exception of type
'System.Runtime .InteropService s.COMException' occurred in
mailclient.exe

Can anybody help me out ?

Regards,
Sentiboy

Sep 6 '06 #2
I just saw your previous similar-veined post, and realized my response may
not be what you are looking for, as you are actually trying to tie into the
Outlook messaging system. I have not dug that deeply into MAPI... I just
needed to be able to *send* email to our local email server from our
automated application. However, you may still find what you are looking for
at the sites I mentioned.

Cheers!

~ Duane Phillips.

"Duane Phillips" <du************ @askme.askmewro te in message
news:Er******** *************** *******@giganew s.com...
Why use an installed client when you can use the DotNet infrustructure,
which has it all built in?

'xxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xx
'SMTP EMAIL NOTES
'As condensed from: http://www.systemwebmail.com/default.aspx
'1. Have a reference set to the System.Web.dll.
'2. Have "Imports System.Web.Mail " statement at the top of your code.
'3. SmtpMail.SmtpSe rver must allow relaying for FROM email address or your
IP address,
' or you must use dotNET 1.1 or higher to authenticate.
'SAMPLE SETTINGS
'Dim emlEmail As New System.Web.Mail .MailMessage()
' NOTE: all email addresses can be like: "my******** @my-domain.com" - OR -
Fully named like: """John Smith"" <my********@m y-domain.com>"
' Also, multiple email addresses can be sent separated by semi-colon
character.
'emlEmail.To = "my******** @my-domain.com"
'emlEmail.From = "my******** @my-domain.com"
'emlEmail.Cc = "my******** @my-domain.com" 'optional
'emlEmail.Bcc = "my******** @my-domain.com" 'optional
'emlEmail.Subje ct = "SUBJECT_HE RE"
'emlEmail.BodyF ormat = MailFormat.Html
'emlEmail.Body = "BODY OF THE MESSAGE HERE"
'emlEmail.Heade rs.Add("Reply-To", "my******** @my-domain.com")
'Attachments()
'Dim attachment As New System.Web.Mail .MailAttachment ("C:\Foo.xls ")
'create the attachment
'emlEmail.Attac hments.Add(atta chment) 'add the attachment
'Authentication cannot be done using the .NET Framework 1.0. Must use 1.1
or higher.
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e",
"1") 'basic authentication
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/sendusername",
"my_username_he re") 'set your username here
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/sendpassword",
"super_secr et") 'set your password here
'SmtpMail.SmtpS erver = "EMAIL_SERVER_D OMAIN" 'your real server goes here
'SmtpMail.Send( emlEmail)
'xxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xx

Please note that the above example is for DotNet 1.x
http://www.systemwebmail.com/

To see more information for 2.x, see http://www.systemnetmail.com/

I have found these two sites very useful.

HTH.

Cheers!

~ Duane Phillips.

<se******@gmail .comwrote in message
news:11******** **************@ d34g2000cwd.goo glegroups.com.. .
>>I am using the following code for sending email through mapi in VS 2005
environment:

Public objSession As New MSMAPI.MAPISess ion
Public objMessage As New MSMAPI.MAPIMess ages

objSession.Down LoadMail = False
objSession.User Name = "MyUsername "
objSession.Pass word = "MyPassword "
objSession.Sign On()
objMessage.Sess ionID = objSession.Sess ionID
objMessage.Comp ose()

objMessage.Reci pAddress = txtTo.Text
objMessage.Text = txtBody.Text
objMessage.Subj ect = txtSubject.Text

objMessage.Send (True) 'ShowDialog
MsgBox("Message sent successfully!")
objSession.Sign Off()

I uninstalled Microsoft Outlook (comes along with msoffice), now my
default client is Outlook Express, I get this exception:

An unhandled exception of type
'System.Runtim e.InteropServic es.COMException ' occurred in
mailclient.e xe

Can anybody help me out ?

Regards,
Sentiboy


Sep 6 '06 #3
I need to do some checking with the latest stuff but the last I looked
around the first of the year, the elegant stuff in the framework wasn't
worth the effort to blow it up IN REAL WORLD APPLICATIONS!

My testing worked great in my office. The moment I took it to a real site -
my client's, not even the motely crew of real end users - it ran into
firewall problems.

I gave up and used VB 6 techniques!

It's on my list to revisit when I get time.

Elegance is all right. Working is better.

Regards,
Al
"Duane Phillips" <du************ @askme.askmewro te in message
news:Er******** *************** *******@giganew s.com...
Why use an installed client when you can use the DotNet infrustructure,
which has it all built in?

'xxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xx
'SMTP EMAIL NOTES
'As condensed from: http://www.systemwebmail.com/default.aspx
'1. Have a reference set to the System.Web.dll.
'2. Have "Imports System.Web.Mail " statement at the top of your code.
'3. SmtpMail.SmtpSe rver must allow relaying for FROM email address or your
IP address,
' or you must use dotNET 1.1 or higher to authenticate.
'SAMPLE SETTINGS
'Dim emlEmail As New System.Web.Mail .MailMessage()
' NOTE: all email addresses can be like: "my******** @my-domain.com" - OR -
Fully named like: """John Smith"" <my********@m y-domain.com>"
' Also, multiple email addresses can be sent separated by semi-colon
character.
'emlEmail.To = "my******** @my-domain.com"
'emlEmail.From = "my******** @my-domain.com"
'emlEmail.Cc = "my******** @my-domain.com" 'optional
'emlEmail.Bcc = "my******** @my-domain.com" 'optional
'emlEmail.Subje ct = "SUBJECT_HE RE"
'emlEmail.BodyF ormat = MailFormat.Html
'emlEmail.Body = "BODY OF THE MESSAGE HERE"
'emlEmail.Heade rs.Add("Reply-To", "my******** @my-domain.com")
'Attachments()
'Dim attachment As New System.Web.Mail .MailAttachment ("C:\Foo.xls ")
'create the attachment
'emlEmail.Attac hments.Add(atta chment) 'add the attachment
'Authentication cannot be done using the .NET Framework 1.0. Must use 1.1
or higher.
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e",
"1") 'basic authentication
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/sendusername",
"my_username_he re") 'set your username here
'emlEmail.Field s.Add("http://schemas.microso ft.com/cdo/configuration/sendpassword",
"super_secr et") 'set your password here
'SmtpMail.SmtpS erver = "EMAIL_SERVER_D OMAIN" 'your real server goes here
'SmtpMail.Send( emlEmail)
'xxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xx

Please note that the above example is for DotNet 1.x
http://www.systemwebmail.com/

To see more information for 2.x, see http://www.systemnetmail.com/

I have found these two sites very useful.

HTH.

Cheers!

~ Duane Phillips.

<se******@gmail .comwrote in message
news:11******** **************@ d34g2000cwd.goo glegroups.com.. .
>>I am using the following code for sending email through mapi in VS 2005
environment:

Public objSession As New MSMAPI.MAPISess ion
Public objMessage As New MSMAPI.MAPIMess ages

objSession.Down LoadMail = False
objSession.User Name = "MyUsername "
objSession.Pass word = "MyPassword "
objSession.Sign On()
objMessage.Sess ionID = objSession.Sess ionID
objMessage.Comp ose()

objMessage.Reci pAddress = txtTo.Text
objMessage.Text = txtBody.Text
objMessage.Subj ect = txtSubject.Text

objMessage.Send (True) 'ShowDialog
MsgBox("Message sent successfully!")
objSession.Sign Off()

I uninstalled Microsoft Outlook (comes along with msoffice), now my
default client is Outlook Express, I get this exception:

An unhandled exception of type
'System.Runtim e.InteropServic es.COMException ' occurred in
mailclient.e xe

Can anybody help me out ?

Regards,
Sentiboy

Sep 6 '06 #4

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

Similar topics

40
11803
by: ian | last post by:
Hi, I'm a newbie (oh no I can here you say.... another one...) How can I get Python to send emails using the default windows email client (eg outlook express)? I thought I could just do the following import win32com.client
0
3683
by: David Burson | last post by:
Hi, I have a VB.NET windows app that needs to automatically send a simple text email when my users run a new version of the app for the first time. I thought this would be simple, but after days of reading posts and testing, I see it is not - unless I'm missing something? I'm not an email guru. All of my users will be running at least...
1
5325
by: Jay McGrath | last post by:
Help - trying to send a simple text email with with as little user intervention. I am trying to create a button in my Access application that will automatically send a simple text email. It works except that I have two warning nuisances: 1) Program is trying to access email Addresses you have stored in Outlook. Allow access for ... 2) A...
2
3123
by: madfisher | last post by:
Hi, I am trying to send an email with MAP via C# and ASP.NET. This is what I'm doing. MapiSession1 = new MSMAPI.MAPISessionClass(); MapiSession1.UserName = "OutlookProfileName"; MapiSession1.Password = "pass"; MapiSession1.LogonUI = false; MapiSession1.SignOn();
15
8571
by: cj | last post by:
How can I get a button in VB to send the contents of a text box via email in a manner similar to the "Send To\Mail Recipient" functionality that you can select via right clicking a file in Windows Explorer? I want the user to click a button and it lunch the users default email client and put the contents of a multi line text box in the body...
3
2823
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and additionally pictures of the product are stored in an images subfolder and the database holds the file name of the relevant picture. The user can then click a...
1
4385
by: Danny | last post by:
Hi Am trying to send emails via simple mapi. The application will be running on a machine which has outlook 2003 installed. My test app works but the file email is placed in the outbox within outlook, and does not get sent until a start outlook and process the waiting emails. Is there any way I can send the emails without the interaction...
0
2041
by: Bill Nguyen | last post by:
I used to be able to have Crystal report send email within a .NET application using "Export" option. Now the option to send mail (Destination MAPI) is no longer available in the Export "Destination" dropdown. How do I get it back? I'm using VS 2005. CR reports version 10 Thanks Bill
1
5023
by: prasadmore | last post by:
I am developing a web service using CDO 1.21 to create an appointement in Exchange Server 2003. The Logon method is executing successfully and able to access Inbox folder. When I try to create an appointement using following code snippet, I get "{" ]"}" error. Not able to understand whether we are missing any property or are we setting the...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5325
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.