check if send message appears in SendItems forder before moving

Status
Not open for further replies.

ludo

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Hi,

I'm using the code below (snipset) to send a mail with a Excel range in the body from within Excel.

This works almost perfect.

The only problem i'll have (randomly) is that i see that the send message isn't always moved to the destination folder.

To avoid this behavior, i would like to check if the send message appears into the Send Items folder before i move it to the destination folder.

Anyone out there who can provide me those few code lines that i need to place between the .send & moving the message to the destination folder (between the 2 red lines in the sub below)?

I think that a kind of loop will do it, but i have no clue on how to code it. All used code so far in this sub comes from different sites, and put it toghether like a jigsaw .

the criteria to look for is: strSubject & Date (green line).

Code below runs from a Excel 2010 worksheet and use late binding.

This makes it easier to distribute or run the worksheet on different PC's without the need to set everywhere a reference to the Outlook 14 vba library.

Sub Mail_Selection_Range_Outlook_Body()

'basic code from:

'http://www.rondebruin.nl/mail/folder3/mail4.htm

' Don't forget to copy the function RangetoHTML in the module.

' Working in Office 2000-2010

'

'adapted & extended by Ludo Soete

'--------------------------------'

<SNIP
'create a new folder to store the mails after sending

'folder name = "Verpakte Units"

'if folder doesn't exist, create it

On Error GoTo errorhandler

Set myDestFolder = mySendMail.Folders("Verpakte Units")

'

On Error Resume Next

With OutMail

> To = strMailToRec1 & ";" & strMailToRec2 & ";" & strMailToRec3 & ";" & strMailToRec4 'strRecipient

> CC = ""

> BCC = ""

> Subject = strSubject & Date

> HTMLBody = strBody1 & "<br>" & "<br>" & strBody2 & "<br>" & strFrom & "<br>" & "<br>" & "Verstuurd om: " & Time & "<br>" & "<br>" & RangetoHTML(rng)

.Send '.Display '

'inform the user that the mail has been send

'dont move this, ensure there's enough time to send so that we can move the mail

If blnMsgboxSendToMessage = True Then

MsgBox "Uw mail werdt verstuurd naar :" & vbCrLf & vbCrLf & strMailToRec1 & vbCrLf & strMailToRec2 & vbCrLf & strMailToRec3 & vbCrLf & strMailToRec4, vbInformation, "Mail verstuurd"

End If

'check if message moved to the SendItems folder before moving to destination folder

'

'move send mail to myDestination folder

Set myItem = myItems.Find("[Subject] =" & strSubject & Date) '

While TypeName(myItem) <> "Nothing"

If myItem.Subject = strSubject & Date Then

myItem.Move myDestFolder

End If

Set myItem = myItems.FindNext

Wend

strDestinationFolder = myDestFolder.Name

strSendMailboxName = mySendMail.Name

'show frmMsgMovedMessage depending on the blnfrmShowMovedMessage value

If blnfrmShowMovedMessage = True Then

frmMsgMovedMessage.Show

End If

End With

End Sub

<SNIP
Thanks for any help

regards,

Ludo
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
M I get the following error message when tryiong to send some emails.__'Relaying denied: You must check for new mail before sending mail.' Using Outlook 2
J Send and Receive Button - only check default account? Using Outlook 1
S Check if two organisition is added then i have to give managers passward creteria to send mail Using Outlook 1
T push "send/receive all folders" and nothing happens, check "Show progress" and it's empty. Using Outlook 10
A send a email, with out having to save contact details, in office 03 and 07 you could uncheck and disable email name check Using Outlook 1
J I have just installed office 2007 on my pc....now when I want to send an email and hit the spell check on the bar it highlights just about every word Using Outlook 1
W How to sign in outlook 2003 from another computer to check my email and send messages Using Outlook 2
L Spell-check dictionary confusion Using Outlook 0
S How to export urls from email to excel and check the status of the url ? New Slipstick.com Articles 6
N Private check box in table view Using Outlook 0
S Outlook to check for specific text Outlook VBA and Custom Forms 3
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
O Outlook 2016 This rule will only run when you check your email in Outlook.... Using Outlook 4
A Check for words in subject header before sending email Outlook VBA and Custom Forms 4
R Using "check for duplicates" for existing contacts Using Outlook 2
P Suppress dialog box on email check error? Using Outlook 5
Potty Ash MS Outlook 2010 custom form - validation or formula to request user to check a checkbox Outlook VBA and Custom Forms 16
I Check if sent email has been replied Outlook VBA and Custom Forms 1
K adding more rules to 'different domains check' macro Outlook VBA and Custom Forms 2
R Macro to check file name with outlook address book Outlook VBA and Custom Forms 0
Diane Poremsky Check Contacts before moving them to Hotmail Contacts folder New Slipstick.com Articles 0
Diane Poremsky Check for missing attachments before sending a message New Slipstick.com Articles 1
R Outlook 2010 Modify Style "Do not check spelling or grammar" not saving Outlook VBA and Custom Forms 0
K check for sender, follow to my personal adress and delete the sent folder. Outlook VBA and Custom Forms 1
A Check for attachment code not working Outlook VBA and Custom Forms 1
Diane Poremsky Check Message Size Before Sending New Slipstick.com Articles 0
B Check for different domains macro to be triggered by specific domains only Outlook VBA and Custom Forms 2
V Check/convert to emailaddresses Outlook VBA and Custom Forms 11
JorgeDario how to check a MailItem has a digital signature (SMIME) with vba? Outlook VBA and Custom Forms 1
O Unable to check name. Using Outlook 3
R Outlook Custom form check if there an attachment Outlook VBA and Custom Forms 2
L Trying to check for the absence of mail. Outlook VBA and Custom Forms 1
Peter H Williams check for new email automaticlly Using Outlook 12
C Unusual Signature & Spell Check Query Using Outlook 1
M Calendar navigation displays previous field records.check calendar is shared.. Using Outlook 3
A Can Rule Check Category Contact is assigned? Using Outlook 1
T Outlook 2007 forms: Check boxes and free text boxes not retaining data Using Outlook 1
C Create a rule to only check new content in email - disregard original content Using Outlook 3
M Outlook Rules check for new line character Using Outlook 1
S Individual Mailbox Check Exchange Server Administration 3
D Inserting check boxes in task requests Outlook 2007 Using Outlook 2
L OWA 2010 Don't want to Spell Check Signature Using Outlook 2
K how to check the exchange server is health or not Exchange Server Administration 2
M spell check in French. Using Outlook 2
A how do I find my second Email account to to check my mail Using Outlook 1
J .TIF Attachments will not open. Error: "Unable ot open document. If this is a Web document, check y Using Outlook 3
E Outlook 2010 won't check for email. Using Outlook 2
P Spell check greyed out in Outlook 2010 Using Outlook 2
B In Contact Properties of Outlook 2010, it does not allow me to check the check box " Show this folde Using Outlook 2
B Re: In Contact Properties of Outlook 2010, it does not allow me to check the check box " Show this f Using Outlook 2
Similar threads


















































Top