Link to home
Start Free TrialLog in
Avatar of eossma
eossma

asked on

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
Avatar of eossma
eossma

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Helen Feddema
Helen Feddema
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
SOLUTION
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 eossma

ASKER

.SentOnBehalfOfName = "blah@blah.com"
doesn't work.  It ignores this statement and sends it from me defualt email address.