473,553 Members | 3,116 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help sending email

B
My code below works fine when run from my pc (changed all the values for
obvious reasons). The code is placed inside a DTS task via VBS scripting.
But when I try to run directly from the server where sqlserver is installed,
the script fails.

I have SMTP running, but there is no outlook installed.

Can someone please advise what I am missing.
Thanks
Bob
Set objEmail = CreateObject("C DO.Message")

objEmail.From = "se**@test. com"
objEmail.To = "re*****@test.c om"
objEmail.Subjec t = "TEST SUBJECT"
objEmail.AddAtt achment "\\server\test. csv"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendusing") = 2
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpserver") = "SERVER_NAM E"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpauthenticat e") = 1
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendusername") = "username"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendpassword") = "userpwd"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpserverport" ) = 25
objEmail.Config uration.Fields. Update
objEmail.Send

set objEmail = nothing
Jun 23 '06 #1
3 2297
Hi B

One thing you might try is change
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendusing") = 2 to objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendusing") = "2"
quotes around the 2.

I spent several hours a week ago trying the very same thing and that made
all the difference.

Also is \\server\test.c sv accessible from the server you are running this
on?

Here is the full text of the DTS Package I wrote. Note that I don't think
all the fields you included are necessary.

'************** *************** *************** *************** ***********
' Visual Basic ActiveX Script
'************** *************** *************** *************** *************

Function Main()
email_alert "dc******@yahoo .com", "Ge*********@wh itehouse.gov"," Test
Subject", "Test Body"
Main = DTSTaskExecResu lt_Success
End Function

Sub email_alert(str To, strFrom, strSubject, strBody)
Dim iConf 'As CDO.Configurati on
Dim imsg 'As CDO.Message
Dim flds

Set imsg = CreateObject("C DO.Message")
Set iConf = CreateObject("C DO.Configuratio n")

Set flds = iConf.Fields

'The http://schemas.microsoft.com/cdo/configuration/ namespace defines
the majority of fields used to set configurations for various CDO objects.
We set and update the following three fields (SendUsing, SMTP_SERVER, and
TimeOut) of the Configuration object:

With flds
.Item("http://schemas.microso ft.com/cdo/configuration/sendusing") =
"2"
.Item("http://schemas.microso ft.com/cdo/configuration/smtpserver") =
"smtp-server.mn.rr.co m"
.Item("http://schemas.microso ft.com/cdo/configuration/smtpconnectiont imeout")
= 10
.Update
End With

Set imsg.Configurat ion = iConf
imsg.To = strTo
imsg.From = strFrom
imsg.Subject = strSubject
imsg.TextBody = strBody
imsg.AddAttachm ent "c:\log\myfile. txt"
imsg.Send
End Sub
--
-Dick Christoph

"B" <no_spam@no_spa m.com> wrote in message
news:Ks******** *************** *******@rcn.net ... My code below works fine when run from my pc (changed all the values for
obvious reasons). The code is placed inside a DTS task via VBS scripting.
But when I try to run directly from the server where sqlserver is
installed,
the script fails.

I have SMTP running, but there is no outlook installed.

Can someone please advise what I am missing.
Thanks
Bob
Set objEmail = CreateObject("C DO.Message")

objEmail.From = "se**@test. com"
objEmail.To = "re*****@test.c om"
objEmail.Subjec t = "TEST SUBJECT"
objEmail.AddAtt achment "\\server\test. csv"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendusing") = 2
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpserver") = "SERVER_NAM E"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpauthenticat e") = 1
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendusername") = "username"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendpassword") = "userpwd"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpserverport" ) = 25
objEmail.Config uration.Fields. Update
objEmail.Send

set objEmail = nothing

Jun 23 '06 #2
B
Follow-up to my original post below.

Is it possible for the "objEmail.T o" to lookup the values from a sqlserver
table?

At the moment, I type the email address separated by a semi-colon.

TIA~
"B" <no_spam@no_spa m.com> wrote in message
news:Ks******** *************** *******@rcn.net ...
My code below works fine when run from my pc (changed all the values for
obvious reasons). The code is placed inside a DTS task via VBS scripting.
But when I try to run directly from the server where sqlserver is installed, the script fails.

I have SMTP running, but there is no outlook installed.

Can someone please advise what I am missing.
Thanks
Bob
Set objEmail = CreateObject("C DO.Message")

objEmail.From = "se**@test. com"
objEmail.To = "re*****@test.c om"
objEmail.Subjec t = "TEST SUBJECT"
objEmail.AddAtt achment "\\server\test. csv"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu ration/sendusing") = 2
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu ration/smtpserver") = "SERVER_NAM E"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu ration/smtpauthenticat e") = 1
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu ration/sendusername") = "username"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu ration/sendpassword") = "userpwd"
objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu ration/smtpserverport" ) = 25
objEmail.Config uration.Fields. Update
objEmail.Send

set objEmail = nothing

Jun 28 '06 #3
Hi B,

Well not directly but you could create an ADODB Command, Connection and
Recordset and use the command to return you a recordset from the Database
that would have 1 or many email addresses that you could concatenate
together and stick in the objEmail.To field.

--
-Dick Christoph
"B" <no_spam@no_spa m.com> wrote in message
news:c4******** *************** *******@rcn.net ...
Follow-up to my original post below.

Is it possible for the "objEmail.T o" to lookup the values from a sqlserver
table?

At the moment, I type the email address separated by a semi-colon.

TIA~
"B" <no_spam@no_spa m.com> wrote in message
news:Ks******** *************** *******@rcn.net ...
My code below works fine when run from my pc (changed all the values for
obvious reasons). The code is placed inside a DTS task via VBS
scripting.
But when I try to run directly from the server where sqlserver is

installed,
the script fails.

I have SMTP running, but there is no outlook installed.

Can someone please advise what I am missing.
Thanks
Bob
Set objEmail = CreateObject("C DO.Message")

objEmail.From = "se**@test. com"
objEmail.To = "re*****@test.c om"
objEmail.Subjec t = "TEST SUBJECT"
objEmail.AddAtt achment "\\server\test. csv"

objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendusing") = 2

objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpserver") = "SERVER_NAM E"

objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpauthenticat e") = 1

objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendusername") = "username"

objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/sendpassword") = "userpwd"

objEmail.Config uration.Fields. Item("http://schemas.microso ft.com/cdo/configu
ration/smtpserverport" ) = 25
objEmail.Config uration.Fields. Update
objEmail.Send

set objEmail = nothing


Jun 30 '06 #4

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

Similar topics

3
1785
by: NotGiven | last post by:
The code below is designed to loop through rows of a database query obtaining email addresses and send an email to each. It is modified form fomr some code I found on the net. With each while loop, it updates the SENT field of the processed row to mark it sent. I have a sleep function in there to slow the processing down to see if that...
8
5457
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I...
2
2214
by: kimberly.shaffer | last post by:
Okay, I can automate sending of multiple emails with records using Groupwise and Access DB. But now what I need to do is send multiple fields associated with one field out automatically and can't figure out how to do it. For instance, my records look like this: strEmail strGroup jjohns@comcast.net catlovers...
1
1262
by: David Hearn | last post by:
I am trying to generate a short text based email and using VBCrlf to break the lines. The problem is that they are being ignored after about the third or fourth line down into the email. I have also tried using Chr(10) & Chr(13) and Environment.NewLine but these didn't help either. Anyone have any idea what is going on? Thanks in advance!
10
3520
by: Max | last post by:
Hi, I am newbie developing a MailList program in asp.net c#. To avoid be considered as a span, a would like to process some messages, stops, process some messages, stops...... What do you recommend ? Help!!!
6
2766
by: \jason via DotNetMonster.com\ | last post by:
currently i am doing a personal website and keep on changing the aspect... finally the finall decision is to have a login page (requirement in asp.net, vb.net) and the login with security part of capturing user computer user name i have done... my problem is .... i need the unregistered user to log in to my site and from there there will...
6
4967
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a...
9
3441
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient oSMTP.Send(oMailMessage) (in this line I am getting the above err)
2
1921
by: ornto | last post by:
Hi, I'm trying to create an application which checks a dynamic web site and on certain events sends an email to me. My problem though is with the email task. By now I made this simple test code: #prova invio email smtpserver = smtplib.SMTP(mailserver) messaggio= "Messaggio di prova" print mail print messaggio
2
234
by: ahmadoubay_20240 | last post by:
The assignment aims at enforcing the encryption and communication techniques. It helps the student in acquiring the necessary knowledge in developing client/server application and in securing data transfer using encryption techniques. Objectives can be summarized as: • Designing and implementing server applications • Designing and...
0
7568
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
7492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8007
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...
0
7852
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5409
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
5133
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3525
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1990
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
1106
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.