Link to home
Start Free TrialLog in
Avatar of sbornstein2
sbornstein2

asked on

.Net/SQL - Best way to send email through exchange server - SQL (not outlook) - anyone done this?

Hello all,

I have an application that I am going to need to send email from.  I have used in the past outlook with CDONTS etc. however it is very messy and usually you have to deal with the security warning issues and use outlook redepemtion etc. to send the emails.  I think it is a very messy and performance beast.   Has anyone sent email through .Net through exchange or a web service for exchange etc?  The client has exchange for their mail server and of course outlook clients connecting to the users mailboxes.

I am trying to find the best solution and also any insight on what things I need to find out like what exchange version, what I will need to setup on the server running the app that is going to send out emails etc.  I am going to have SQL Server also where then email addresses exist.  I want it to be as seamless as possible and not hold up the app. The app is going to loop and send out multiple emails on an hourly basis.

Thanks all
Avatar of CompanionCube
CompanionCube
Flag of United States of America image

How about this piece of VBS code?

~~~


Sub DropEmail(MsgFrom, MsgTo, MsgSubject, MsgBody)
'on error resume next
Dim iConf

Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing")  = 2
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "someexchangeserver.yourdomain.local"
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport")   = 25
Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous ' 0
Flds.Update

WScript.Echo "Attempting to send email using smtp server: " & someexchangeserver.yourdomain.local

Dim iMsg
set iMsg = CreateObject("CDO.Message")
With iMsg
  Set .Configuration = iConf
    .To          = MsgTo
    .From        = MsgFrom
    .Sender      = MsgFrom
    .Subject     = MsgSubject
    .TextBody    = MsgBody
'    .HTMLBody    = MsgBody
    .Send
End With

'on error goto 0    
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of CompanionCube
CompanionCube
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sbornstein2
sbornstein2

ASKER

It is going to be emailed attachmented excel files to the email.  I need to attach a created excel ti the email and then send.