Avatar billede Carlo Juniormester
17. oktober 2018 - 13:14 Der er 13 kommentarer og
1 løsning

Data sendt til email

Hej -

Jeg har en database hvor data løbende blive sendt pr. mail. Strukturen i mailen skal være [kampID]-[hjemmeholdsscore]-[udeholdsscore]-[hjemmeholdsmål]-[udeholdsmål]

Et eksempel kunne være: 00012-25-12-3-2
Avatar billede jakobdo Ekspert
17. oktober 2018 - 16:10 #1
Så dit spørgsmål er hvordan en email i det format, "pakkes ud" og indsættes i din database eller opdateres ?

Så du skal "bare" finde noget VBA kode, der kan forbinde til din mailserver, udlæse emails der matcher din struktur og så er du i mål. :)
Avatar billede terry Ekspert
17. oktober 2018 - 18:28 #2
"Jeg har en database hvor data løbende blive sendt pr. mail."
So sending the emails is working but you want to format the Body of the email with

"00012-25-12-3-2" ?
Avatar billede Carlo Juniormester
17. oktober 2018 - 20:51 #3
Having the information in the header would also be fine. Dosn't matter - just looking for a solution:-)

Just making sure - the database is to receive data from mails. From the database the flows into Power BI and on to a webpage.
Avatar billede terry Ekspert
18. oktober 2018 - 09:25 #4
Carlo, I understand Danish 'perfectly' ;-)

I'm not I understand what your requirement is :-(

"Jeg har en database hvor data løbende blive sendt pr. mail."
Does this mean that you are already sending emails "løbende" or does it mean you want to ?

Perhaps you should explain in more detail, what you have already and what you want.
Thanks
Avatar billede Carlo Juniormester
20. oktober 2018 - 23:22 #5
Ok - jeg prøver på dansk. Lige nu har jeg en database med en resultattabel, som jeg opdaterer manuelt.

I stedet for manuel opdatering ville jeg gerne hvis tabellen blev opdateret, når der kom nye indberetning via mail. Hvad der sker med data efterfølgende er ikke så vigtigt
Avatar billede terry Ekspert
21. oktober 2018 - 09:39 #6
what mail system are you using, Outlook?
Avatar billede terry Ekspert
21. oktober 2018 - 09:42 #7
And how is the data delivered, file attachment or in the Body?

As there is no quick and easy solution, you will need to be able to write code using VBA
Avatar billede Carlo Juniormester
21. oktober 2018 - 22:54 #8
Think the result is to be put in the header. Do you have an exampel of the needed VBA code?
Avatar billede terry Ekspert
22. oktober 2018 - 09:56 #9
There is no VBA code for a finished solution as its specific for your requirements which I'm afraid to say are still unclear :-(

I still dont know if your are receiving the mail with data or sending the mail with data, or which system you are using to receive/send, Outlook for example.

So I would like you to describe what you want in more detail, step by step so we can better understand what needs to be made.

Once we know what needs to be made its easier to say if we can help or not.
Avatar billede Carlo Juniormester
22. oktober 2018 - 14:39 #10
Hey Terry,

The situation is that I would like resultat send to me on mails. The content header of the mail holds the information eg. [gameID]-[score1]-[score2]-[score3]-[score4] for each game.

The result is to loaded into an access tabel, which have the same 5 columns. The gameID is uniq.

'Carlo'
Avatar billede jakobdo Ekspert
22. oktober 2018 - 15:10 #11
What is the question?
How to create the email or how to get the data into your access?
Avatar billede terry Ekspert
22. oktober 2018 - 16:28 #12
You stil haven't said which mail system you are using :-(

This VBA Code is for Outlook, anything else then you need to look elsewhere ;-)

In your Inbox you need a folder named Scores and another named Finished
You also need to set a filer up so that mails with the data you are receiving gets moved to Scores. The Finished folder is for that that have been processed.

At the moment all we do is write the data to the debug window, and the data is in the body.

Once you get this working we can take it  a step further :-)

Function SaveScore()
Dim myApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myAflsuttetFolder As Outlook.MAPIFolder
Dim myMsg As Outlook.MailItem
Dim a As Integer


Set myApp = CreateObject("Outlook.Application")
Set myNameSpace = myApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)

Set myWorkingFolder = myFolder.Folders("Scores")

Set myFinishedFolder = myFolder.Folders("Finished")



    For Each myMsg In myWorkingFolder.Items
        With myMsg
           
                Debug.Print Trim(myMsg.Body)
               
                myMsg.Move myFinishedFolder
               
        End With
    Next
   
    Set myMsg = Nothing
    Set myFinishedFolder = Nothing
    Set myWorkingFolder = Nothing
    Set myNameSpace = Nothing
    Set myApp = Nothing
   
End Function
Avatar billede Carlo Juniormester
22. oktober 2018 - 16:40 #13
jakobdo: Getting data from mails into access

Terry: I asume outlook but is not sure. Thanks for your input so far!
Avatar billede terry Ekspert
22. oktober 2018 - 17:30 #14
"I asume outlook but is not sure." !!

Well I think it would be one of the first things you need to find out before we go any further.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester