Jump to content
Macro Express Forums

Help To Check Data In Mail


koden

Recommended Posts

My macro copies this (see below) data from a mail into another program.

No problem about that.

 

But sometimes the mail comes twice the same day. No problem if it comes the day after. Only a problem the same day.

If the mail comes again it just have to be deleted.

 

To find out if it comes a second time, i have to check if the field

"job" and the field "code" are the same.

 

How do I do that???

 

My idea is that my macro at first opens the mail and a empty notepad.

 

Copy "job" and "code" content into a variable.

Then the macro has to check if the content of the variable already exist in the notepad.

 

If it does, then delete the mail and empty the variabel.

If not, then fill out the notepad with the content of the variable.

 

Or do you guys have a better idea???

The subject field in the mail always is named the same.

So I can't use the subject field to determine the mail.

 

 

 

 

Job : WPDPVGT1

- Owner : 8775 Impl. Insurance

- code : X505

- Stepname : ????????

- Procname : ????????

- Jobnumber : JOB03442

- Application : APDPDVAGTA

- Workstation : CPU1

- Operation text : Send connect til DPLVAGT

- Start Time : 06.00.00

- Stop Time : 06.00.00

- Date : 02-01-2004

Link to comment
Share on other sites

Or do you guys have a better idea???

Not sure if it is a better idea, but:

 

1) Set a string variable to hold all emails, say T10

2) Within a loop

3) Copy an email into a different string, say T11

4) Test T10 to determine if it contains a job and code of the email in T11

5) If not, paste T11 into Notepad

6) Append T10 with T11

7) If so, then delete email

8) End of loop

Link to comment
Share on other sites

Maybe... It looks better.

But i'm not sure that I understand it fully...Imean to do in practice..

 

I forgot to tell that it's only mails where job AND code are the same as in an earlier mail, that should be deleted.

NOT mails with the same job but diff. code or mails with same code but diff. job

Link to comment
Share on other sites

Use string compares and the OR logical statement for your test. Here is more detail on how to structure your macro:

 

T10 = ""
Start Repeat Loop
  T11 = Current Email
  T1 = The "Code" in T11
  T2 = The "Job" in T11
  If T10 does not contain T1
     OR
  If T10 does not contain T2
     Paste T11 into Notepad
     Append T10 with T11
  Else
     Delete email
  End If
End Repeat Loop

Link to comment
Share on other sites

OOhhhh...Thanks..

I will try this.

 

But is the macro able to see if "code" and "job" already exist in T10, when there in T10 are 30 emails content???

 

Is it not more safe to copy "job" and "code" and only this 2 from each mail and put them to T10?

Instead of this content from each mail:

 

Job : WPDPVGT1

- Owner : 8775 Impl. Insurance

- code : X505

- Stepname : ????????

- Procname : ????????

- Jobnumber : JOB03442

- Application : APDPDVAGTA

- Workstation : CPU1

- Operation text : Send connect til DPLVAGT

- Start Time : 06.00.00

- Stop Time : 06.00.00

- Date : 02-01-2004

Link to comment
Share on other sites

  • 2 weeks later...

I think there is a problem in this.

T10 has to remember the data 24 hours.

The macro can be running many times in one day.

And so far as I have understand T10 will be empty after each run ???

 

maybe T10 should be a notepad document instead ????

 

Ex:

 

When I start at work i run the macro first time this day.

 

Activate and launch program "save all job and code for this day.txt".

T11 = Current Email

T5 = The "Code" in T11

T6 = The "Job" in T11

If "save all job and code for this day.txt" does not contain T1

OR

If "save all job and code for this day.txt" does not contain T2

Paste T11 into T2

Append "save all job and code for this day.txt" with T11

Else

Delete email

End If

 

 

What would you say to this???

I surpose that if "save all job and code for this day.txt" contains T1 but not T2, then it will paste T11 into T2

Link to comment
Share on other sites

I surpose that if "save all job and code for this day.txt" contains T1 but not T2, then it will paste T11 into T2

That is correct. An OR statement only needs one test to be true. Just so you understand, the opposite of what you wrote is:

If "save all job and code for this day.txt" contains T1
AND
If "save all job and code for this day.txt" contains T2
  Delete email
Else
  Paste T11 into T2
  Append "save all job and code for this day.txt" with T11
End If

But the results of the above are identical to your code. (notice that commands inside the If/Else/End If construct are reversed).

Link to comment
Share on other sites

a little problem.

How do I check that notepad document has T1 and T2 ???

 

I can't find a function that can activate notepad and check contain of the notepad document ???

 

Or do I have first to copy all from the notepad into a T variable and check on this T variable ???

Link to comment
Share on other sites

I can think of two ways to check the contents of Notepad.

 

You could highlight the entire content (Ctrl-a), copy it to the clipboard (Ctrl-v), copy from the clipboard to a variable, and check the content of the variable.

 

Or

 

You could use a Window Control, copy the content of the Window Control to a variable, and then check the content of the variable.

Link to comment
Share on other sites

Hello again

 

This problem I had here is now working.

 

But now I have one more variable that I have to check on.

In the mail there is a date

Ex. like this 23-03-2006

 

This date i copy to variable T15

 

 

The macro should only delete mails that has same job and code on the SAME DATE. NOT delete if job and code are the same but have another date.

 

But I can't see how I will get it to check on this date also??

 

Do you understand, or should I write it more specific???

Link to comment
Share on other sites

The problem is on mondays, where the macro has to run mails from friday, saterday and sunday.

There can be job and codes that are simular friday and again sunday.

But when job and code are simular on 2 diff. days it's okay, and mails should not be deleted...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...