|
[x]
Posted via EE Mobile
|
|
| Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
|
|
|
|
Asked by s_puff in VB Script, Microsoft Development, Visual Basic Programming
I am trying to convert some code from VBA to VBS to send an e-mail of an output file. When I run the VBS I don't get any errors and everything seems to work fine but I never recieve the e-mail. This same code works when I run it from VBA. I have attached the line of code that calls SendEmail. The correct values are in each of the variables that calls SendEmail. I think that there may be something wrong in my Send Email sub.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
|
'Calls SendEmail
SendEmail cfgMAILTO, cfgMAILFROM, cfgMAILSUBJECT, cfgMAILSERVER, "", cfgSCRIPTPATH & cfgERRORLOGFILE
Private Sub SendEmail(eTO, eFROM, eSubject, eMailServer, eTEXT, eAttachPath)
'Send an email
'The minimum requirements are: TO, FROM, SUBJECT and MailServer
'when sending a file attachment: eAttachPath is also required
'default parameters not supported in VBS so all parameters must be sent even if Attach not used
Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
Dim FileName
Dim Flds
Dim iMsg
Dim iConf
Const cdoSendUsingPort = 2
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.fields
'set the CDO configuration
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = eMailServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
'verify the attachment exists
If FSO.FileExists(eAttachPath) Then FileName = eAttachPath
'compose and send the email
With iMsg
Set .Configuration = iConf
.To = eTO
'.CC = eCC 'removed CC/BCC parameters from procedure call
'.BCC = eBCC
.From = eFROM
.Subject = eSubject
.TextBody = eTEXT
'check if filename is blank before attaching
If FileName <> "" Then .AddAttachment FileName
.Send
End With
End Sub
|
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625