A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

custom action: save or delete email after sending



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11  
Old December 5th 07, 02:03 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default custom action: save or delete email after sending

This is a VBA user form? If so there is no hWnd property exposed. You have
to get the hWnd using the Win32 API function FindWindow().

FindWindow() takes 2 arguments: window class and caption. You can leave the
window class as a null string or you can use a tool like Spy++ to get the
class name when a UserForm is being displayed. The caption would be whatever
you set it to. After that you use the hWnd that you got for the other calls.
hWnd would be a 32-bit unsigned integer, in VBA terms a Long.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Robin" wrote in message
...
Hi Ken
I have come back this and am still struggling. I am struggling to get the
hWnd for the UserForm. (error: compile error, method or data member not
found). I am struggling to get anything on the internet. The code so far:

Public HWND_TOPMOST As Integer
Public SWP_NOSIZE
Public SWP_NOMOVE
Public SWP_NOACTIVATE

Private Declare Sub setWindowPos Lib "User" (ByVal hWnd As Long, ByVal
hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As
Long,
ByVal cy As Long, ByVal wFlags As Long)

Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objFolder As Outlook.MAPIFolder
Dim oSent As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace

WND_TOPMOST = -1
SWP_NOSIZE = &H1
SWP_NOMOVE = &H2
SWP_NOACTIVATE = &H10

If Item.Class = olMail Then
UserForm1.Show
Call setWindowPos(UserForm1.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE
Or SWP_NOMOVE Or SWP_NOACTIVATE)
If answer = "No" Then 'No from UserForm1, I do not want to save the
email

On Error Resume Next
Set objNS = Application.GetNamespace("MAPI")
Set oSent = objNS.GetDefaultFolder(olFolderSentMail)
Set objFolder = oSent.Folders("Temp Sent") 'Assume this is a mail
folder

If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If

If Application.ActiveInspector Is Nothing Then 'Require that this
procedure be called for an open item
Exit Sub
End If

If Application.ActiveInspector.CurrentItem.Class olMail Then
Exit Sub
End If

Set Item.SaveSentMessageFolder = objFolder

Set objFolder = Nothing
Set oSent = Nothing
Set objNS = Nothing

End If
End If

End Sub

Your help would be greatly appreciated...



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom action Ian Outlook - General Queries 9 April 23rd 07 09:05 PM
Save while sending email in Outlook Marc C Outlook and VBA 1 December 19th 06 06:55 PM
Custom Action DLL with VB? Menachem Bazian Outlook - General Queries 4 August 18th 06 01:58 AM
Outlook 2003 Custom Action on Outgoing Email Rules Pankaj Outlook and VBA 1 June 25th 06 09:35 AM
custom action adubb Outlook - Using Forms 1 March 30th 06 08:17 PM


All times are GMT +1. The time now is 03:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.