Forward on move to IMAP foder
Forward on move to IMAP foder
I would like to automatically forward messages to a differend account if I move them into a special IMAP folder.
Background: I use a helpdesk system that polls a service account. But sometimes service related mails arrive in my personal inbox. Currently I create the case manually by copy/pasting sender address and content. If I forward the message in the client the case is of course created for me. So I thought it would be great if I could just move the message into an IMAP folder "service" and it is moved to the service account in the background and later picked up by the helpdesk system. I would like not to have to include the service mail account in my client.
Background: I use a helpdesk system that polls a service account. But sometimes service related mails arrive in my personal inbox. Currently I create the case manually by copy/pasting sender address and content. If I forward the message in the client the case is of course created for me. So I thought it would be great if I could just move the message into an IMAP folder "service" and it is moved to the service account in the background and later picked up by the helpdesk system. I would like not to have to include the service mail account in my client.
Re: Forward on move to IMAP foder
Look at public IMAP folders
https://www.hmailserver.com/documentati ... otocolimap
https://www.hmailserver.com/documentati ... otocolimap
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation
Re: Forward on move to IMAP foder
Thanks for that hint, unfortunately my Helpdesk system does not pick up mails from the public folder.
Re: Forward on move to IMAP foder
So you don't know how to write a script ??
SørenR.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Re: Forward on move to IMAP foder
I do know but I did not find a hook to react on. Something like "something arrives in a folder, forward it to that address.
I thought about writing a small delphi app that polls the folder and the forwards to my service account but I thought it could be done more easy.
I thought about writing a small delphi app that polls the folder and the forwards to my service account but I thought it could be done more easy.
Re: Forward on move to IMAP foder
what client are you using? this can also be achived with some rules at client level i think.
Katip
--
HMS 5.7.0 x64, MariaDB 10.4.10 x64, SA 3.4.2, ClamAV 0.101.2 + SaneS
--
HMS 5.7.0 x64, MariaDB 10.4.10 x64, SA 3.4.2, ClamAV 0.101.2 + SaneS
Re: Forward on move to IMAP foder
I prefer a server solution as I often use a very simple Mail app on my Android phone on the road.
Re: Forward on move to IMAP foder
Well... I have various hMailServer scripts running on my server - all triggered by Windows Scheduler and not events. One script runs every 30 seconds and check my IDS system and create AutoBans ... Most of my high CPU scripts run outside EventHandlers.vbs in order not to stress the core business of the server (sending and receiving email).mschumann wrote: ↑2020-07-25 18:55I do know but I did not find a hook to react on. Something like "something arrives in a folder, forward it to that address.
I thought about writing a small delphi app that polls the folder and the forwards to my service account but I thought it could be done more easy.
Anyways ... This small piece of code IS NOT VERIFIED! IT MAY WORK OR IT MAY CRASH! I will know more when I can free up my spare server and try it out.
VBS code... DO NOT RUN!
User named "HelpDesk" with password "Password" must exist and have permission to Read/Delete items in Public Folder "HelpDesk".
Code: Select all
Dim i, oApp, oDomain, oAccount, oInboxFolder, oPublicFolder, oMessages
Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate("HelpDesk", "Password")
Set oPublicFolder = oApp.Settings.PublicFolders.ItemByName("HelpDesk")
Set oMessages = oPublicFolder.Messages
If oMessages.Count > 0 Then
Set oDomain = oApp.Domains.ItemByName("domain.tld")
Set oAccount = oDomain.Accounts.ItemByAddress("helpdesk@domain.tld")
Set oInboxFolder = oAccount.IMAPFolders.ItemByName("INBOX")
For i = 0 To oMessages.Count - 1
Rem Following two lines are commented out in case someone tries to run the script
Rem Call oMessages.Item(i).Copy(oInboxFolder.ID)
Rem Call oMessages.DeleteByDBID(oMessages.Item(i).ID)
Next
End If
SørenR.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Re: Forward on move to IMAP foder
Thanks a lot this is great and a good starting point, the rest should be easy. I was tied to writing code in the HMailServer events and found no suitable one.
Re: Forward on move to IMAP foder
Server still runs, nothing crashed... Code changed due to weird internal IMAPFolder handling.
Script lists messages in public folder "HelpDesk" and create a clone adressed to "helpdesk@domain.tld". When done the list of processed messages in public folder "HelpDesk" is deleted.
Set Windows Scheduler to run e.g. every 5 minutes ...
Script: helpdesk.vbs
Script lists messages in public folder "HelpDesk" and create a clone adressed to "helpdesk@domain.tld". When done the list of processed messages in public folder "HelpDesk" is deleted.
Set Windows Scheduler to run e.g. every 5 minutes ...
Script: helpdesk.vbs
Code: Select all
Dim i, oApp, oPublicFolder, oMessages, newMessage, strFilename, oFSO, DBID, MessageArray
Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate("Administrator", "Secret") ' <=== CHANGE THIS!
Set oPublicFolder = oApp.Settings.PublicFolders.ItemByName("HelpDesk") ' <=== CHANGE THIS!
Set oMessages = oPublicFolder.Messages
Set MessageArray = CreateObject("System.Collections.ArrayList")
If oMessages.Count > 0 Then
Set oFSO = CreateObject("Scripting.FileSystemObject")
MessageArray.Clear
For i = 0 To oMessages.Count - 1
MessageArray.Add oMessages.Item(i).ID
Set newMessage = CreateObject("hMailServer.Message")
strFilename = newMessage.Filename
oFSO.CopyFile oMessages.Item(i).Filename, strFilename, True
newMessage.RefreshContent
newMessage.AddRecipient "HelpDesk", "helpdesk@domain.tld" ' <=== CHANGE THIS!
newMessage.Save
Next
For Each DBID In MessageArray
oMessages.DeleteByDBID(DBID)
Next
End If
SørenR.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Re: Forward on move to IMAP foder
I am just speechless.
I created the public folder, installed your script and it worked immediately. If we both were near by and there was no corona I would have liked to invite you for a meal of your choice!
Thanks a lot. This will very much improve my workflows!
I created the public folder, installed your script and it worked immediately. If we both were near by and there was no corona I would have liked to invite you for a meal of your choice!
Thanks a lot. This will very much improve my workflows!
Re: Forward on move to IMAP foder
No problem, When Corona is over and you find yourself in Denmark (Havnsø) you can buy me a beer

SørenR.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.