Results 1 to 5 of 5
  1. #1
    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: Need Help with a Macro (2002)

    Please do not create a new thread every day for the previous day's project. The Lounge has very powerful editing features that let you update your original post to add more information, or you can reply in the same thread with more information. When you create multiple threads for the same project, it becomes difficult to follow your objectives and can lead to a lot of wasted time telling people things they could have read the first time around. (Sometimes it is necessary, in which case please include a link to the previous thread for background.)

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Need Help with a Macro (2002)

    Danny,
    To combine the two, you need something like:
    <pre>Dim SafeItem, oItem
    Set SafeItem = CreateObject("Redemption.SafeMailItem")
    Set oItem = activeinspector.currentitem
    SafeItem.Item = oItem
    </pre>

    etc.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    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: Need Help with a Macro (2002)

    Hmm, I should have mentioned that when you edit your message, you should make clear which is the new part.

    Anyway, here's an example of how to rewrite the original procedure for Redemption. What I find is that the message sits in my Drafts folder until I do a Send/Receive. There is some code online to force an immediate send, but I don't recommend using it unless timing is critical.
    <pre>Sub CompleteAndSend()
    ' Step #1: Create a reference to the open message
    ' OLD (native Outlook):
    'Dim msg As Outlook.MailItem
    'Set msg = ActiveInspector.CurrentItem
    ' NEW (Redemption library):
    Dim oMsg As Outlook.MailItem
    Set oMsg = ActiveInspector.CurrentItem
    Dim msg As Object
    Set msg = New Redemption.SafeMailItem
    msg.Item = oMsg

    ' Step #2: Set the subject line and send the message
    With msg
    .Subject = "Your Resume"
    .Send
    End With
    If Not (msg Is Nothing) Then Set msg = Nothing
    ' NEW:
    ' Needed in Outlook 2002 SP3, not sure about other versions
    oMsg.Close SaveMode:=olPromptForSave
    If Not (oMsg Is Nothing) Then Set oMsg = Nothing
    ' NOTE: Maybe necessary to press Send/Receive at this point,
    ' see http://www.dimastr.com/redemption/faq.htm#1

    ' Step #3: Delete the selected message in the active folder
    'Exit Sub 'Uncomment for testing without deleting
    With ActiveExplorer.Selection
    If .Count = 1 Then
    .Item(1).Delete
    Else
    ' What to do if multiple messages are selected?
    End If
    End With
    End Sub</pre>

    Hope this helps.

  4. #4
    New Lounger
    Join Date
    Jul 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help with a Macro (2002)

    <P ID="edit" class=small>(Edited by dmarsh on 03-Aug-04 01:49. )</P>Edited 08/02/04

    Thanks for your most recent reply regarding my quest for an Outlook Macro to automate my daily emailing. Unfortunately, I received the following message: "Compile Error: User-defined type not defined" after the line that reads "Set msg = New Redemption.SafeMailItem". Below is the entire macro . . . any ideas what may be causing this message? Thanks again for your help!!!

    Sub CompleteAndSendTest()
    ' Step #1: Create a reference to the open message
    ' OLD (native Outlook):
    'Dim msg As Outlook.MailItem
    'Set msg = ActiveInspector.CurrentItem
    ' NEW (Redemption library):
    Dim oMsg As Outlook.MailItem
    Set oMsg = ActiveInspector.CurrentItem
    Dim msg As Object
    Set msg = New Redemption.SafeMailItem .....................Error message occurs here
    msg.Item = oMsg
    ' Step #2: Set the subject line and send the message
    With msg
    .Subject = "Your Resume"
    .Send
    End With
    If Not (msg Is Nothing) Then Set msg = Nothing
    ' NEW:
    ' Needed in Outlook 2002 SP3, not sure about other versions
    oMsg.Close SaveMode:=olPromptForSave
    If Not (oMsg Is Nothing) Then Set oMsg = Nothing
    ' NOTE: Maybe necessary to press Send/Receive at this point,
    ' see http://www.dimastr.com/redemption/faq.htm#1
    ' Step #3: Delete the selected message in the active folder
    'Exit Sub 'Uncomment for testing without deleting
    With ActiveExplorer.Selection
    If .Count = 1 Then
    .Item(1).Delete
    Else
    ' What to do if multiple messages are selected?
    End If
    End With
    End Sub
    =================
    Hello -

    Not knowing anything about macros, I have combined the two macros below based on a reply that I received. Unfortunately, the "answer" ended with etc...... being such a macro novice, I believe something missing from "etc..........." is still causing me to receive the SendMail Warning (5 second delay). Any further advice to how this macro should be written?

    Thanks!

    Sub Test()
    Dim SafeItem, oItem
    Set SafeItem = CreateObject("Redemption.SafeMailItem")
    Set oItem = ActiveInspector.CurrentItem
    SafeItem.Item = oItem
    Dim msg As Outlook.MailItem
    Set msg = ActiveInspector.CurrentItem
    ' Set the subject line and send the message
    With msg
    .Subject = "Your Resume"
    .Send
    End With
    If Not (msg Is Nothing) Then Set msg = Nothing
    ' Delete the selected message in the active folder
    With ActiveExplorer.Selection
    If .Count = 1 Then
    .Item(1).Delete
    Else
    ' What to do if multiple messages are selected?
    End If
    End With
    End Sub

    =====================

    Hello -

    I'm still attempting to automate my daily emailing . . . In my attempt to do so, I have a macro that will do what I need to do; however, I receive the dreaded Outlook Email Warning when sending an email via a macro. To get around this, I would informed to make use of the Redemption Library (which I have installed). Unfortunately, I'm not experienced with macros so I was wondering if anyone might know how to combine an example of a Redemption macro I found relating to sending email and my send macro?

    My current macro:

    Sub CompleteAndSend()
    ' Create a reference to the open message
    Dim msg As Outlook.MailItem
    Set msg = ActiveInspector.CurrentItem
    ' Set the subject line and send the message
    With msg
    .Subject = "Your Resume"
    .Send
    End With
    If Not (msg Is Nothing) Then Set msg = Nothing
    ' Delete the selected message in the active folder
    With ActiveExplorer.Selection
    If .Count = 1 Then
    .Item(1).Delete
    Else
    ' What to do if multiple messages are selected?
    End If
    End With
    End Sub

    An example of a Redemption Macro that I believe I need to integrate with my above macro:

    Sub Redemption_Example()

    Dim SafeItem, oItem
    Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
    Set oItem = Application.CreateItem(0) 'Create a new message
    SafeItem.Item = oItem 'set Item property
    SafeItem.Recipients.Add "somebody@somewhere.com"
    SafeItem.Recipients.ResolveAll
    SafeItem.Subject = "Testing Redemption"
    SafeItem.Send
    End Sub

    Thanks for your help!
    Danny

  5. #5
    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: Need Help with a Macro (2002)

    You wrote:
    <hr>Edited 08/02/04

    Thanks for your most recent reply regarding my quest for an Outlook Macro to automate my daily emailing. Unfortunately, I received the following message: "Compile Error: User-defined type not defined" after the line that reads "Set msg = New Redemption.SafeMailItem". Below is the entire macro . . . any ideas what may be causing this message? Thanks again for your help!!!<hr>
    If the VBA compiler does not recognize Redemption.SafeMailItem, perhaps you did not set a reference to the Redemption library? Try this: Tools>References..., scroll down to SafeOutlook Library and check it and click OK to add it to your project. If you try Debug>Compile, it should work now.

    If you have further comments, please reply to the message you are commenting on, as this thread is beoming hard to follow.

Posting Permissions

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