Automatically modifying an email

Status
Not open for further replies.

scottb2

Member
Since I can't seem to get attachments to work with "mailto" (see my previous post "URL opening a new email"), I'm thinking about another way. If I were to issue the following URL in IE:


mailto:me@test.com?cc=him@test.com,attachment=c:\t.txt&subject=this%20is%20a%20subject&body=this%20is%20a%20body​





which places the filename to be attached in the "To" line. I'd then programatically remove the filename from the "To" line and add the attachment.




I'm not sure how to run my code just by creating the email with the URL. Also, is it possible to remove an address from the "To" list? Any pointers are appreciated.




Thanks,


Scott
 
D

Dmitry Streblechenko

You cannto add attachments through the mailto protocol.

Dmitry Streblechenko (MVP)

-

"scottb2" <scottb2.47ybta@invalid> wrote in message

news:scottb2.47ybta@invalid...

> Since I can't seem to get attachments to work with "mailto" (see my
> previous post "URL opening a new email"), I'm thinking about another
> way. If I were to issue the following URL in IE:
> mailto:me@test.com?cc=him@test.com,attachment=c:\t.txt&subject=this%20is%20a%20subject&body=this%20is%20a%20body

> which places the filename to be attached in the "To" line. I'd then
> programatically remove the filename from the "To" line and add the
> attachment.

> I'm not sure how to run my code just by creating the email with the
> URL. Also, is it possible to remove an address from the "To" list? Any
> pointers are appreciated.

> Thanks,
> Scott

> > scottb2
> >
 

scottb2

Member
True, but in the first email, I described a method of getting around the problem. I'm using mailto to open an email and fill in everything except for the attachment. I then need to gain control by handling some event and then using Item.Attachment to create the attachment.




So I have two problems. The first problem is how to let my code know what is supposed to be attached. By specifying a fake "To" address (as described in the first email), the code can do the right thing. I then only need to know how to get control. Would a NewInspector event handled in the ThisOutlookSession module do the job?




Is the "fake To: address" method workable? Is NewInspector the event that ThisOutlookSession should be using to get control?




I'm trying to go about it this way because there should be only two keys hit once the information is selected: the first causes the mailto command to be constructed and issued and the second submits the email. I can't have any more keys hit to manually attach a file, manually select the email, etc.




Scott




You cannto add attachments through the mailto protocol.





--


Dmitry Streblechenko (MVP)








-


"scottb2" <scottb2.47ybta@invalid> wrote in message


news:scottb2.47ybta@invalid...

>

> Since I can't seem to get attachments to work with "mailto" (see my

> previous post "URL opening a new email"), I'm thinking about another

> way. If I were to issue the following URL in IE:

> mailto:me@test.com?cc=him@test.com,attachment=c:\t.txt&subject=this%20is%20a%20subject&body=this%20is%20a%20body

>

> which places the filename to be attached in the "To" line. I'd then

> programatically remove the filename from the "To" line and add the

> attachment.

>

> I'm not sure how to run my code just by creating the email with the

> URL. Also, is it possible to remove an address from the "To" list? Any

> pointers are appreciated.
 
K

Ken Slovak - [MVP - Outlook]

The mailto: protocol opens an Outlook item using Simple MAPI.

In Outlook 2002 or later you do get that Inspector added to the Inspectors

collection, but there is no NewInspector() event. There are no events

telling you an item was added. That's true even in Outlook 2010.

The only way I've found to do what you want to do is to use a timer to check

the Inspectors collection against a list of handled Inspectors. I use

Inspector wrappers and wrapper collections anyway, so the infrastructure is

there already for me in any of my addins. If I find an unhandled Inspector I

know it's a Simple MAPI Inspector (which are opened modally, BTW).

Of course there are a number of flags I have to maintain and various

interlocks to make sure I don't handle a normal Outlook Inspector in both

NewInspector() and my timer event handler and end up handling an Inspector

twice. And I double-check on matching Inspectors with more than captions,

for example getting the Inspector window handle and then checking the window

RECT and screen position for a match, among other things. There are a number

of fault use cases where simple matching fails.

A fake To address could work but the item has to be saved to fill that in.

"scottb2" <scottb2.48364a@invalid> wrote in message

news:scottb2.48364a@invalid...

> True, but in the first email, I described a method of getting around the
> problem. I'm using mailto to open an email and fill in everything
> except for the attachment. I then need to gain control by handling some
> event and then using Item.Attachment to create the attachment.

> So I have two problems. The first problem is how to let my code know
> what is supposed to be attached. By specifying a fake "To" address (as
> described in the first email), the code can do the right thing. I then
> only need to know how to get control. Would a NewInspector event
> handled in the ThisOutlookSession module do the job?

> Is the "fake To: address" method workable? Is NewInspector the event
> that ThisOutlookSession should be using to get control?

> I'm trying to go about it this way because there should be only two
> keys hit once the information is selected: the first causes the mailto
> command to be constructed and issued and the second submits the email.
> I can't have any more keys hit to manually attach a file, manually
> select the email, etc.

> Scott
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
B Zoom automatically next email item (VBA) Outlook VBA and Custom Forms 2
Paul Hobbs Automatically accept "Empty Folders" prompt Outlook VBA and Custom Forms 6
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
M Automatically add senders first name to a greeting Outlook VBA and Custom Forms 1
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
J Automatically forward email and apply template Outlook VBA and Custom Forms 0
Y Outlook 2013 Stop Outlook from automatically assigning categories to Tasks Using Outlook 0
O Forward a email with modified body Automatically. Outlook VBA and Custom Forms 0
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
P Automatically Categorize Meetings once they are accepted Outlook VBA and Custom Forms 5
W Automatically open attachments without automatically printing them Using Outlook 0
N How to set automatically the default or user defined Quickstyle Templates by Answer in Outlook Using Outlook 1
O Run macro automatically at sending an email Using Outlook 11
D Outlook 2016 automatically increment anniversaries Using Outlook 1
T Office 2013 no longer updating automatically Using Outlook 2
B Automatically Forward Emails and Remove/Replace All or Part of Body Outlook VBA and Custom Forms 8
D Print attachments automatically and moves the mail to a new folder Outlook VBA and Custom Forms 9
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
L Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 33
N how to sync automatically when outlook opens Using Outlook 10
A Sort emails into subfolders based on sender and deleting emails automatically Outlook VBA and Custom Forms 3
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1
R Make Enter Network Password Prompt Go Away Automatically Using Outlook 0
I Print Automatically Attachments Outlook VBA and Custom Forms 3
S Automatically selecting folders and deleting messages in Outlook VBA Outlook VBA and Custom Forms 7
M Outlook 2016 Rules Not Working Automatically Using Outlook 5
Diane Poremsky Automatically create a task when sending a message Using Outlook 0
D Is it possible to automatically send an email when it is moved to a folder? Exchange Server Administration 1
A Automatically send email based on drop-down field? Outlook VBA and Custom Forms 2
M Automatically create event in calendar when task is created Outlook VBA and Custom Forms 1
Diane Poremsky Create Appointment From Email Automatically Using Outlook 0
Cameron Piper Automatically update custom forms across multiple computers Outlook VBA and Custom Forms 1
T Automatically open link in email received Outlook VBA and Custom Forms 33
N Automatically file email messages Using Outlook 2
J Automatically Move Old Items from a Shared Mailbox to a .PST on a Network Drive Outlook VBA and Custom Forms 1
M Change default "automatically test account settings when Next is clicked" Using Outlook 1
D Automatically file message and reply to folder. Using Outlook 1
A Code to automatically delete message after sending Outlook VBA and Custom Forms 6
Diane Poremsky Automatically Create Contacts From Messages Using Outlook 1
T Outlook 2010 emails do not refresh automatically Exchange Server Administration 1
L Save Mail Message to new folder created automatically Outlook VBA and Custom Forms 1
G Hae Rules NOT perform automatically? Using Outlook 1
F Automatically close email after selecting mark unread Using Outlook 1
nathandavies How to save emails to a specific folder on a network automatically using a macro Outlook VBA and Custom Forms 14
T Default inbox not automatically sending/receiving Using Outlook 1
Angger Microsoft Outlook 2010 Automatically Restarting Using Outlook 2

Similar threads

Top