473,387 Members | 3,787 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,387 software developers and data experts.

Cannot Send Mail Through Outlook without Outlook Open

I'm trying to send using outlook but I get an error on the directcast line
if I don't have outlook open. Works fine if it is open. What do I need to
do to be able to send without having outlook open? Thanks

Dim objOutlook As New Outlook.Application

Dim objMail As Outlook._MailItem =
DirectCast(objOutlook.CreateItem(Outlook.OlItemTyp e.olMailItem),
Outlook._MailItem)

Dim mSubject As String

Dim mBody As String

mSubject = client & " - " & fDescription.Text

mBody = ControlChars.CrLf & "file:" & fFilename.Text & ControlChars.CrLf &
ControlChars.CrLf &

With objMail

..BodyFormat = Outlook.OlBodyFormat.olFormatRichText

..To = us**@domain.com

..Subject = mSubject

..Body = mBody

..Send()

End With

objMail = Nothing

objOutlook = Nothing
Nov 21 '05 #1
6 3524
On Tue, 21 Sep 2004 19:27:17 -0500, "Barkster" <bd***@hotmail.com> wrote:

¤ I'm trying to send using outlook but I get an error on the directcast line
¤ if I don't have outlook open. Works fine if it is open. What do I need to
¤ do to be able to send without having outlook open? Thanks
¤
¤ Dim objOutlook As New Outlook.Application
¤

Try the following instead of the above line of code:

Dim objOutlook As Outlook._Application
objOutlook = New Outlook.Application()
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #2
will do, thanks

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:49********************************@4ax.com...
On Tue, 21 Sep 2004 19:27:17 -0500, "Barkster" <bd***@hotmail.com> wrote:

¤ I'm trying to send using outlook but I get an error on the directcast line ¤ if I don't have outlook open. Works fine if it is open. What do I need to ¤ do to be able to send without having outlook open? Thanks
¤
¤ Dim objOutlook As New Outlook.Application
¤

Try the following instead of the above line of code:

Dim objOutlook As Outlook._Application
objOutlook = New Outlook.Application()
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 21 '05 #3
Tried that and got the same error, stops on line
Dim objMail As Outlook._MailItem =
DirectCast(objOutlook.CreateItem(Outlook.OlItemTyp e.olMailItem),
Outlook._MailItem)
with the following error

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in ScanMail.exe

"B-Dog" <bd***@hotmail.com> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
will do, thanks

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:49********************************@4ax.com...
On Tue, 21 Sep 2004 19:27:17 -0500, "Barkster" <bd***@hotmail.com> wrote:
¤ I'm trying to send using outlook but I get an error on the directcast line
¤ if I don't have outlook open. Works fine if it is open. What do I

need to
¤ do to be able to send without having outlook open? Thanks
¤
¤ Dim objOutlook As New Outlook.Application
¤

Try the following instead of the above line of code:

Dim objOutlook As Outlook._Application
objOutlook = New Outlook.Application()
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)


Nov 21 '05 #4
On Wed, 22 Sep 2004 10:44:03 -0500, "B-Dog" <bd***@hotmail.com> wrote:

¤ Tried that and got the same error, stops on line
¤ Dim objMail As Outlook._MailItem =
¤ DirectCast(objOutlook.CreateItem(Outlook.OlItemTyp e.olMailItem),
¤ Outlook._MailItem)
¤
¤
¤ with the following error
¤
¤ An unhandled exception of type 'System.Runtime.InteropServices.COMException'
¤ occurred in ScanMail.exe

What is ScanMail? Is it anti-virus software for Exchange?
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #5
Didn't notice that, I'll have to look into it. Thanks

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:li********************************@4ax.com...
On Wed, 22 Sep 2004 10:44:03 -0500, "B-Dog" <bd***@hotmail.com> wrote:

¤ Tried that and got the same error, stops on line
¤ Dim objMail As Outlook._MailItem =
¤ DirectCast(objOutlook.CreateItem(Outlook.OlItemTyp e.olMailItem),
¤ Outlook._MailItem)
¤
¤
¤ with the following error
¤
¤ An unhandled exception of type 'System.Runtime.InteropServices.COMException' ¤ occurred in ScanMail.exe

What is ScanMail? Is it anti-virus software for Exchange?
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 21 '05 #6
Figured it out, wasn't logining in using using mapi and profile

Try

'now need to send to Jack from list

Dim objOutlook As Outlook._Application

Dim OLNameSpace As Outlook.NameSpace

Dim objMail As Outlook.MailItem

Dim mSubject As String

Dim mBody As String

objOutlook = New Outlook.Application

OLNameSpace = objOutlook.GetNamespace("MAPI")

OLNameSpace.Logon()

objMail = CType(objOutlook.CreateItem(Outlook.OlItemType.olM ailItem),
Outlook.MailItem)

mBody = ""

mSubject = "Daily Attendance"

Dim icount As Integer

For icount = 0 To lbAttend.Items.Count - 1

mBody &= CType(CType(lbAttend.Items(icount), DataRowView)("Description"),
String) & ControlChars.CrLf

Next

With objMail

..BodyFormat = Outlook.OlBodyFormat.olFormatRichText

..To = "ba*****@domain.com"

..Subject = mSubject

..Body = mBody

..Send()

End With

OLNameSpace.Logoff()

OLNameSpace = Nothing

objMail = Nothing

objOutlook = Nothing

Catch ex As Exception

MsgBox(ex)

End Try

End Sub
Nov 21 '05 #7

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

Similar topics

11
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
3
by: Mike B | last post by:
Ok anybody got any good ideas on how to send a fax from ASP.NET. I have an exchange server available with a ms faxserver running both on a different machine to the web server. Mike
1
by: Michele | last post by:
Hi, I need to send the same Email to different people. I'm using Outlook XP and VB.Net. I tryed with the following code: Dim oOutL As Outlook.Application Dim oMail As Outlook._MailItem oOutL...
15
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...
17
by: rdemyan | last post by:
My app creates a building report. My users have requested that I provide functionality to e-mail these "building reports" to building managers once a month. So assuming that I have the...
16
by: Kosmos | last post by:
Good afternoon everyone, just wondering if anyone knew if it's possible to send meetings or appointments through email when you run VBA or SQL code in Access 2003? The following is the code I've been...
9
by: ARC | last post by:
In case anyone has ran into this yet. The following code used to work with older versions of the MS Outlook library, but would error out in 2007: Dim objOutlook As Outlook.Application Dim...
1
by: sxwend | last post by:
I am trying to use the following post results (http://www.thescripts.com/forum/thread189759.html) and add another requirement. I need to send the results to just the email addresses that the query...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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,...
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
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.