Bulk add email addresses to Distribution List
Bulk add email addresses to Distribution List
I would like to add about 50 emails to a distribution list, and the emails will change every few weeks, so a simple copy/paste into a memo box would be ideal. Adding each address one by one will be far too time consuming. Is there any chance you can change the interface in a future build?
Thanks!
Thanks!
Re: Bulk add email addresses to Distribution List
My guess is that would be highly unlikely to happen since it is achievable through scripting.
hMail core is designed to be a lightweight core without feature bloat except it provides a COM API which allows system administrators to do pretty much anything they like if they are prepared to learn the COM API which can be accessed via any programming/scripting language which can access COM.
See following VBScript as an example of what can be done. It doesn't do exactly what you require but should set you on the path to do what you want. You can modify to create a distribution list and/or add/delete members to distribution list instead of new accounts and aliases.
And please post working copy of result for others benefit if you get it going.
http://www.hmailserver.com/forum/viewto ... 10#p151855
Also read up on COM API and scripting from online docs.
Good Luck
p.s. the following may or may not be of use. I haven't used it so don't know if it has what you are looking for. Link is to last/latest version I think
http://www.hmailserver.com/forum/viewto ... a8#p148326
hMail core is designed to be a lightweight core without feature bloat except it provides a COM API which allows system administrators to do pretty much anything they like if they are prepared to learn the COM API which can be accessed via any programming/scripting language which can access COM.
See following VBScript as an example of what can be done. It doesn't do exactly what you require but should set you on the path to do what you want. You can modify to create a distribution list and/or add/delete members to distribution list instead of new accounts and aliases.
And please post working copy of result for others benefit if you get it going.
http://www.hmailserver.com/forum/viewto ... 10#p151855
Also read up on COM API and scripting from online docs.
Good Luck
p.s. the following may or may not be of use. I haven't used it so don't know if it has what you are looking for. Link is to last/latest version I think
http://www.hmailserver.com/forum/viewto ... a8#p148326
Re: Bulk add email addresses to Distribution List
That's all great if everyone is a programmer but that's a small proportion of users. I do happen to be a programmer but not in VB. It shouldn't be a big job, perhaps 15 minutes to alter the HMailServer source code to make it a memo box rather than an edit box and update the database in bulk. It would make it much more user friendly.
Re: Bulk add email addresses to Distribution List
Since you're a programmer and its only going to take you 15mins to fix what you want then please feel free to do so.
You can get the source code from
http://www.hmailserver.com/forum/viewto ... 10&t=21837
it may have moved to
http://svn.hmailserver.com/
You can get the source code from
http://www.hmailserver.com/forum/viewto ... 10&t=21837
it may have moved to
http://svn.hmailserver.com/
Re: Bulk add email addresses to Distribution List
The first link is correct.
I got it wrong earlier.
I got it wrong earlier.
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: Bulk add email addresses to Distribution List
I only know Delphi (Object Pascal) and probably wouldn't have the time anyway. It would solve a distribution issue I have when sending software updates to my users. Sending one email with 50 BCC recipients often causes the email to be regarded as spam. I really need individually addressed emails but using Office Outlook to send. I know there are commercial clients out there that can do this but it would be nice to send an email to one address and know it's gone to everyone.
Re: Bulk add email addresses to Distribution List
I doubt thatrlevis wrote:Sending one email with 50 BCC recipients often causes the email to be regarded as spam
unless there are multiple recipients at a single domain, no-one would ever know (that's the point of BCC).
Try ALSO sending to yourself as TO and see if that changes anything for you...
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: Bulk add email addresses to Distribution List
That's what I do. But several mail servers seem to prefer the recipient in the To address and less likely to be regarded as spam. I have resent emails that were deleted as spam to the To address and then it gets through.mattg wrote:Try ALSO sending to yourself as TO and see if that changes anything for you...
Re: Bulk add email addresses to Distribution List
are you using a relay sender?
Re: Bulk add email addresses to Distribution List
No, just MS-Office Outlook with BCC email addresses.
Re: Bulk add email addresses to Distribution List
Some email clients (and web hosted services) will put mail where the recipient is in BCC into SPAM, but the recipient should be able to add exclusions for mail from you.
Sending 50 separate emails is just a pain.
Setting the members of a distribution list via the COM API from a txt file shouldn't be hard to achieve... I'll play when I get time
Sending 50 separate emails is just a pain.
Setting the members of a distribution list via the COM API from a txt file shouldn't be hard to achieve... I'll play when I get time
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: Bulk add email addresses to Distribution List
That would be most appreciated.mattg wrote:Setting the members of a distribution list via the COM API from a txt file shouldn't be hard to achieve... I'll play when I get time
Re: Bulk add email addresses to Distribution List
OK
In example list of email addresses in a text file called testlist.txt which is located in C:\Temp\ (this can be changed)
List is one address per line
Don't run with the hMailserver administrator open as it throws an error. Instead open it afterwards to check results.
Save file below as 'filename.vbs', and then simply double click on it to run.
It will throw a Message box if it doesn't like a line in the text file, otherwise there is no feedback.
If the distribution list doesn't exist it will create it, if it exists it will delete all recipients.
Let me know if you have issues.
In example list of email addresses in a text file called testlist.txt which is located in C:\Temp\ (this can be changed)
List is one address per line
Don't run with the hMailserver administrator open as it throws an error. Instead open it afterwards to check results.
Save file below as 'filename.vbs', and then simply double click on it to run.
It will throw a Message box if it doesn't like a line in the text file, otherwise there is no feedback.
If the distribution list doesn't exist it will create it, if it exists it will delete all recipients.
Let me know if you have issues.
Code: Select all
Option Explicit
Dim oApp, oDomain, oDistributionList, OBJfile, FileIn, FSO, s, i, j, bExists
Const HMSADMINUSER = "administrator"
Const HMSADMINPWD = "SecretPassword" 'CHANGE ME
oDomain = "domain.com" 'CHANGE ME
oDistributionlist = "testlist@domain.com" 'CHANGE ME
filein = "c:\Temp\testlist.txt" 'CHANGE ME
bExists = false
Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate(HMSADMINUSER, HMSADMINPWD)
for i = 0 to oApp.Domains.itemByName(oDomain).Distributionlists.count -1
if oApp.Domains.itemByName(oDomain).Distributionlists.Item(i).address = oDistributionList then
for j = oApp.Domains.itemByName(oDomain).Distributionlists.item(i).recipients.count -1 to 0 step -1
oApp.Domains.itemByName(oDomain).Distributionlists.item(i).recipients.item(j).delete
next 'j
bExists = true
end if
next 'i
If Not bExists then
with oApp.Domains.itemByName(oDomain).Distributionlists.add()
.address = oDistributionList
.RequireSMTPAuth = false
.Active = true
.Mode = 0
.save
end with
end if
oApp.Domains.itemByName(oDomain).Distributionlists.refresh
Set FSO = CreateObject("Scripting.FileSystemObject")
set OBJfile = FSO.opentextfile(filein,1,0)
While Not OBJfile.atendofstream
s = OBJfile.readline
If ValidEmail(s) = true then
with oApp.Domains.itemByName(oDomain).Distributionlists.ItemByAddress(oDistributionList).recipients.add()
.RecipientAddress = s
.save
end with
else
msgBox("Invalid entry - " & s)
end if
Wend
OBJfile.close
set OBJfile = nothing
oApp.Domains.itemByName(oDomain).Distributionlists.refresh()
Function ValidEmail(ByVal emailAddress)
Dim objRegEx, retVal
Set objRegEx = CreateObject("VBScript.RegExp")
With objRegEx
.Pattern = "^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$"
.IgnoreCase = True
End With
retVal = objRegEx.Test(emailAddress)
Set objRegEx = Nothing
ValidEmail = retVal
End Function
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: Bulk add email addresses to Distribution List
what about following TLDs
.museum
.travel
only kidding

.museum
.travel
only kidding
Re: Bulk add email addresses to Distribution List
Go ahead, update the regex that I downloaded somewhere and borrowed
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: Bulk add email addresses to Distribution List
Matt,
I think the regex you posted is fine for 99.9% of email address validation. To make any email address validation 100% accurate via regex isn't the way to go. A lookup from IANA for current and live TLDs would be required and you can't do that with Regex. So limiting TLD to 4 chars is fair enough. If you really wanted to include Museum and Travel then you'd need upto 6 chars which is simple enough with
but any regex like this is only a partial attempt at validation and allowing 6 chars for TLD will let through a lot more domain name errors. So hence my "only kidding". Regex is just a helper for email format being correct and not a true validation tool in this case. It could be done but would be massively long and complicated so just isn't worth it.
I think the regex you posted is fine for 99.9% of email address validation. To make any email address validation 100% accurate via regex isn't the way to go. A lookup from IANA for current and live TLDs would be required and you can't do that with Regex. So limiting TLD to 4 chars is fair enough. If you really wanted to include Museum and Travel then you'd need upto 6 chars which is simple enough with
Code: Select all
^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}\b$