[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1035
  • Last Modified:

Redemption Outlook Process Code Gets Stuck in Draft Folder

I have 2 problems:
1. Upon execution, with the .Save command line, this code get's stuck in Outlook's Draft folder and does not get sent; however, .Send will only send the first recipient in the list
2. I would like to use the .From line (currently commented out), but this makes the entire code fail - with no error messages

Here's the code:
Private Sub Reminder_Click()
    Dim rs          As DAO.Recordset            ' recordset of suppliers (for email address)
    Dim objOutlook  As Object                   ' outlook object
    Dim objMessage  As Outlook.MailItem         ' outlook mail message
    Dim strOrder    As String                   ' string of order details
    Dim objSafeMail As Object
    On Error GoTo SendObject_Error
   
    Set objOutlook = CreateObject("Outlook.Application")
    Set rs = CurrentDb.OpenRecordset("SELECT* FROM qryEmail WHERE tblRegistrants.AddressID= " & Me!AddressID)

    While Not rs.EOF
        strOrder = "ENROLLMENT REMINDER" & _
            vbCrLf & vbCrLf & _
            "You are scheduled to attend the class on " & [CRSE] & " held " & [CourseDate] & " @ " & [StartOfCourse] & " - " & [EndOfCourse] & ". " & _
            vbCrLf & vbCrLf & _
            "IMPORTANT" & _
            vbCrLf & _
            "If for some reason you need to cancel, please reply to this email or call me @ (000) 000-000.  Some classes have a waiting list and others may wish to take your spot.  Please give them the opportunity to do so." & _
            vbCrLf & vbCrLf & _
            "Thank you." & _
            vbCrLf & vbCrLf & _
            vbCrLf & _
            "Blagh" & _
            vbCr & _
            "Blah" & _
            vbCr & _
            "blah, Inc." & _
            vbCr & _
            "blah" & _
            vbCr & _
            "000-000-0000 Office"
           
        If Not IsNull(rs("Email")) Then
          Set objMessage = objOutlook.CreateItem(olMailItem)
            With objMessage
                .To = rs("Email")
                '.From = "blah@gmail.com"
                .Subject = "ENROLLMENT REMINDER !  -  " & [CRSE] & " on " & [CourseDate] & ""
                .BodyFormat = olFormatHTML
                .HTMLBody = "<HTML><HEAD><TITLE></TITLE></HEAD><BODY><FONT face=Verdana><FONT size=2><STRONG><U>ENROLLMENT REMINDER</STRONG></U><BR><BR>You are scheduled to attend the class on <FONT color=#0000ff><b>" & [CRSE] & "</FONT></B> held <FONT color=#0000ff><b>" & [CourseDate] & "</FONT></B> @ " & [StartOfCourse] & " - " & [EndOfCourse] & ".<BR><BR><STRONG><U>IMPORTANT</U></STRONG><BR>If for some reason you need to cancel, please reply to this email or call me @ (000) 000-0000.  Some classes have a waiting list and others may wish to take your spot.  Please give them the opportunity to do so.<BR><BR>Thank you.<BR><BR><BR><B>blah<BR><U>lah</U></B><BR>blah, Inc.<BR>blag<BR>(000) 000-0000 Office</FONT></BODY></HTML>"
                .Importance = olImportanceHigh  'High importance
                .Save
            End With
        End If
     
        Set objSafeMail = CreateObject("Redemption.SafeMailItem")
        objSafeMail.Item = objMessage

        'Send
        objSafeMail.Send
        rs.MoveNext
    Wend
   
    ' tidy up
    rs.Close
    Set rs = Nothing
    Set objOutlook = Nothing
    Set objMessage = Nothing

SendObject_Error:
    If Err.Number = 2501 Then
       MsgBox "You have cancelled the e-mail; thus, it was not sent.", vbInformation, "Notice!"
   End If
   
End Sub
0
eossma
Asked:
eossma
  • 2
  • 2
2 Solutions
 
eossmaAuthor Commented:
Actually, I retract item number 1.  It works, it just works really slow.

However, I will still provide the 500 points if someone can tell me why the from line doesn't work, and how can i get it to work?

Additional infor that might help.  I have two email accounts tied to my Outlook account.  One is my personal company account (set as the default in Outlook), the second is my department's general email address.  I would like to use the latter for the code above.  Why doesn't it work?
0
 
Helen FeddemaCommented:
The Redemption Library is no longer needed in Access 2007 (at least, if you have the latest updates).  I guess Microsoft heeded the complaints about the Object Model Guardian!  So you can remove the code that uses Redemption objects and just use regular Outlook objects, and the message should go into the Outbox and be sent (in that case, use msg.Send, not just Send).

For the problem with the From line, this is one of those annoying Outlook field name mismatches.  The field is shown as From in the interface (even in Design view), but in code it is SentOnBehalfOfName.  You can try setting that property, but I am not sure whether it can be set manually.

0
 
Helen FeddemaCommented:
I meant Office 2007 -- I assume you have the same version of Outlook and Access.
0
 
eossmaAuthor Commented:
.SentOnBehalfOfName = "blah@blah.com"
doesn't work.  It ignores this statement and sends it from me defualt email address.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now