Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving non-sent email (OL98)

    Hi,
    I wrote this code in Office 2000 in Excel, its supposed to prepare emails to be posted, check that the address is valid then save them to the 'drafts' folder. This works great in 2000 but nothing appears to happen in OL98, It gets as far as the .save and thats it. Nothing is saved, there are no error messages, zilch, nil and again nothing. The code is as follows:
    Sub SendMessage()
    '----------------------------------------------------------------
    '--- This is required to prevent a name which does not resolve to
    ' an e-mail address from hanging the app.
    '----------------------------------------------------------------
    On Error Resume Next

    '---------------------------------
    ' Create the Outlook session.
    '---------------------------------
    Set objOutlook = CreateObject("Outlook.Application")

    '---------------------------------
    ' Create the message.
    '---------------------------------
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
    '----------------------------------------
    ' Add the To recipient(s) to the message.
    '----------------------------------------
    Set objOutlookRecip = .Recipients.Add(CustomerAddress)
    objOutlookRecip.Type = olTo

    '------------------------------------------------------
    ' Set the Subject, Body, and Importance of the message.
    '------------------------------------------------------
    .Subject = "Survey " & CallNo
    .Body = CustomerMessage
    .Importance = olImportanceLow 'Low importance

    '---------------------------------
    ' Add attachments to the message.
    '---------------------------------
    If Not IsMissing(attachmentPath) Then
    Set objOutlookAttach = .Attachments.Add(attachmentPath, , , "ICL
    Call Survey")
    End If

    '---------------------------------
    ' Resolve each Recipient's name.
    '---------------------------------
    For Each objOutlookRecip In .Recipients
    objOutlookRecip.Resolve
    If Not objOutlookRecip.Resolve Then
    Range("D" & x - 1).Select
    ActiveCell.Value = "Recipient Not resolved"
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    Exit Sub
    End If
    Next
    .Save ' Save as Draft
    End With

    '-----------------------------------------------------------
    '--- Remove the message and Outlook application from memory.
    '-----------------------------------------------------------
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    End Sub
    Can anyone help me.

    Regards Jim

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Saving non-sent email (OL98)

    Try putting a stop statement on the line after "'Resolve each Recipient's name" and step through it in the de###### to see if your message object is getting destroyed in the loop before you get to Save. Or just before save, add:

    MsgBox "Message is dead: " & objOutlookMsg Is Nothing

    Other than that, no ideas. I don't have 98 to test.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •