5 Replies Latest reply on Feb 20, 2012 2:23 PM by SH_INT

    Error with Send Mail Accelerator

    user9510887
      I am trying to use the send mail accelerator code to generate an e-mail notification. My code is below. This is the first time I have used this so I'm not sure if I am missing something. I am getting an error that says "At least one of the From or Sender fields required, and neither was found. At line 58." Line 58 is ".Send" towards the bottom of the script? Is there something that needs to be added to this line?



      'Declare local variables
      Dim strFromAddress
      Dim strToAddress
      Dim strSubject
      Dim strEmailMsgLine
      Dim objMsg
      Dim objConfig
      Dim intSendUsing
      Dim strSMTPServer
      Dim intSendPort

      'Initialize message content variables
      strFromAddress = DW.Security.fUserEmailGet(DW.Connection.PstrUserID)
      strToAddress = me@usp.org
      strSubject = "FDM Load Status"
      strEmailMsgLine = "This is the status of the current load"

      'Initialize Mail Server variables
      'SMTP server name
      strSMTPServer = "the.usp.org"
      'CdoSendUsing enumeration-1=use smtp on local machine, 2=use smtp over network
      intSendUsing = 2
      'SMTP port on server
      intSMTPPort = 25

      'Create CDO configuration object
      Set objConfig = CreateObject("CDO.Configuration")     
      'Set Config object settings
      With objConfig.Fields
           .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = intSendUsing
           .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPServer
           .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")= intSMTPPort
           .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
           .Update
      End With

      'Create CDO message object
      Set objMsg = CreateObject("CDO.Message")     
      'Assign config object to configuration property of message object
      Set objMsg.Configuration = objConfig
      'Set Message object settings and send mail
      With objMsg
           .To = strToAddress
           .From = strFromAddress
           .Subject = strSubject
           .TextBody = strEmailMsgLine
           .Send
      End With

      'Destroy message objects
      Set objMsg = Nothing
      Set objConfig = Nothing

      End Sub
        • 1. Re: Error with Send Mail Accelerator
          SH_INT
          Problem is probably due to this line

          strFromAddress = DW.Security.fUserEmailGet(DW.Connection.PstrUserID)

          not actually retrieving an email address. Have you set up an email in FDM user maintenance for the user you are running the script under? Hard code an email here and I imagine the script will work or simply fill in an email for the users in user maintenance
          • 2. Re: Error with Send Mail Accelerator
            user9510887
            Ok, that worked. Once I entered the admin's e-mail address in user maintenance the e-mail genereated. Thanks for your help.

            However, the only thing that shows up in the body of the e-mail is "This is the status of the current load", which is what I typed in on the "strEmailMsgLine" line. So my question is, what should show up in the e-mail? How do I get this to show some valuable infomation? Does the script need to be added to a load action or event script?
            • 3. Re: Error with Send Mail Accelerator
              SH_INT
              That is a bit of an arbitary question. It all depends on where in the context of workflow you are and what information you are hoping to send to the user. If you find answers helpful in the forum please mark as such. Also I wouldn't advise marking a post as anwered if you post a follow up question.
              • 4. Re: Error with Send Mail Accelerator
                user9510887
                Sorry for the confusion. I am just trying to get an understanding of how others may be using the e-mail capability.

                So to be more specific, we are using the batch loader to load the current month and prior month Actuals daily. In the batch loader script, we are able to write a batch loader report to the file system that details the status of the data loads. Ideally I would like to put this report in the body of the email that is generated.

                I think now that I have the e-mail working I can play around with the script to see if I can get exactly what I want.
                • 5. Re: Error with Send Mail Accelerator
                  SH_INT
                  You could simply attach the generated report to the email. There should be a .Attachment property of the send mail object, just point that to the report file.