Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programmers' lounge. (Programming-related discussions only)
New Posts  All Forums:Forum Nav:

Programmers' lounge. (Programming-related discussions only) - Page 68

post #671 of 1143
Quote:
Originally Posted by andyroo89 View Post

Ok, peeps, a friend of mine has a small business, and he wants to send out email newsletters. He wants it to be automated, and he asked me if I can make a program for him to do that. I told him he can just add the recipients and do a mass email but, he insisted on having me make him a program.

So, how I have it so far, it uses smtp and I told him he just needs to put his username and password so it will use his gmail account. I also added a multiline textbox where you can add multiple emails (he has a notepad of the emails he wants to send newsletters too, which is why I had that idea to do that) But the problem I am having is, how would I go about having the program read the first line of the email address, send the email and wait a couple of seconds and goes to the next line and does the same thing.

I know I need to use a loop in some way, and tbh idk where to go from there if I need a stream reader or input stream reader.
You could do something like this:

Instead of pasting in all the emails, put in the path to the file.
Then you can do something like this:

foreach (var line in File.ReadAllLines(path))
{
//send emails
Thread.Sleep(2000); //or await Task.Delay(2000)
}
post #672 of 1143
Quote:
Originally Posted by 3930K View Post

You could do something like this:

Instead of pasting in all the emails, put in the path to the file.
Then you can do something like this:

foreach (var line in File.ReadAllLines(path))
{
//send emails
Thread.Sleep(2000); //or await Task.Delay(2000)
}

I actually added a opefile dialog to load the emails to the textbox.
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
post #673 of 1143
Hi, the first thing you need to do is to open that notepad of emails(which should be character delimited meaning the email address should be in a format that you can segregate each emails example


email1.yahoo.com;email2.yahoo,com;email3.yahoo.com (example of semi colon segregation)

email1.yahoo.com
email2.yahoo.com
email3.yahoo.com (example of end line or enter segregation)

i would consider using example 2(end line or enter segration) because its readable to the user when adding or removing emails. Next thing you need to do is to traverse that notepad using the preferred formatting by using stream reader. Try this

Another possibility is to just read the whole file as a block into a single string and the SPLIT the string on vbcrlf

Dim buf = My.Computer.FileSystem.ReadAllText(Filename)
Dim Lines() = Split(Buf, vbcrlf)
Then, lines will contain all the lines from the file, indexed.

So you could step through them to get each player and his other info.

For x = 0 to ubound(Lines)
'do whatever with each line
next
If the file was HUGE, you wouldn't necessarily want to do it this way, but for small files, it's a quick and easy way to handle it.



OR

you can create a module for inserting emails to a database.
Quote:
Originally Posted by andyroo89 View Post

Ok, peeps, a friend of mine has a small business, and he wants to send out email newsletters. He wants it to be automated, and he asked me if I can make a program for him to do that. I told him he can just add the recipients and do a mass email but, he insisted on having me make him a program.

So, how I have it so far, it uses smtp and I told him he just needs to put his username and password so it will use his gmail account. I also added a multiline textbox where you can add multiple emails (he has a notepad of the emails he wants to send newsletters too, which is why I had that idea to do that) But the problem I am having is, how would I go about having the program read the first line of the email address, send the email and wait a couple of seconds and goes to the next line and does the same thing.

I know I need to use a loop in some way, and tbh idk where to go from there if I need a stream reader or input stream reader.
KM
(14 items)
 
KTechDev
(5 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX 6100 Asrock 990FX Extreme 4 Powercolor 7870 2GB Gskill RipjawX 1600 CL9D 8GB 
Hard DriveOptical DriveCoolingOS
500GB WD Caviar Blue SATA 3.0 Samsung 22x SH-S222/223 Sata Noctua NH-D14 Windows 7 Ultimate 64bit 
MonitorPowerCase
21.5 Samsung LED Monitor Corsair GS800W Thermaltake Armor A60 
CPUMotherboardRAMOS
Intel Pentium G620 2.6GHz ASRock Z68 Pro3-M Corsair XMS 3 1333 8gb Windows Server 2008 R2 
Power
Antec Basic VP350W 
  hide details  
Reply
KM
(14 items)
 
KTechDev
(5 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX 6100 Asrock 990FX Extreme 4 Powercolor 7870 2GB Gskill RipjawX 1600 CL9D 8GB 
Hard DriveOptical DriveCoolingOS
500GB WD Caviar Blue SATA 3.0 Samsung 22x SH-S222/223 Sata Noctua NH-D14 Windows 7 Ultimate 64bit 
MonitorPowerCase
21.5 Samsung LED Monitor Corsair GS800W Thermaltake Armor A60 
CPUMotherboardRAMOS
Intel Pentium G620 2.6GHz ASRock Z68 Pro3-M Corsair XMS 3 1333 8gb Windows Server 2008 R2 
Power
Antec Basic VP350W 
  hide details  
Reply
post #674 of 1143
I'd personally split it into lines and then do:
Code:
foreach(string email in File.ReadLines(emailFilePath))
{
   //send email
   await Task.Delay(20);
}
post #675 of 1143
Quote:
Originally Posted by 3930K View Post

I'd personally split it into lines and then do:
Code:
foreach(string email in File.ReadLines(emailFilePath))
{
   //send email
   await Task.Delay(20);
}

+1
Pretty much wouldn't even bother looking any further past this sort of implementation.
If you're loading from a file to a text box for no benefit other than to just use the contents of the file, you can skip the text box step.
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #676 of 1143
Hey guys. I'm trying to generate a bunch of struct arrays for a program I'm creating, but for some reason it won't work.

Here's the code in C
Code:
#include <stdio.h>
#include <stdlib.h>

typedef struct{
    int clave;
    char nombre[50];
}DataBox;

typedef DataBox RegistroOrdenable;

int main()
{
    int n = 20000;
    RegistroOrdenable orig_box1[n];
    RegistroOrdenable orig_box2[n];
    RegistroOrdenable orig_box3[n]; //burbuja
    RegistroOrdenable box1[n];
    RegistroOrdenable box2[n];
    RegistroOrdenable box3[n];
    RegistroOrdenable box4[n];
    RegistroOrdenable box5[n];
    RegistroOrdenable box6[n];
    RegistroOrdenable box7[n];
    RegistroOrdenable box8[n];
    RegistroOrdenable box9[n];
    RegistroOrdenable box10[n];
    RegistroOrdenable box11[n];
    RegistroOrdenable box12[n]; //seleccion
    RegistroOrdenable box13[n];
    RegistroOrdenable box14[n];
    RegistroOrdenable box15[n]; //shellsort


    printf("Hello world!\n");

    return 0;
}

It manages to create orig_box1, but when it tries to generate orig_box 2 then the compiler throws a SIGSEV signal, segmentation fault. For some reason it works for up to 2,000 blocks in each array, but above that, it won't work.

Is there any way to fix this? I'm thinking I'll have to use dynamic memory for this. frown.gif
fr0sty
(20 items)
 
SnowFlake
(5 items)
 
 
CPURAMHard DriveHard Drive
Intel Core i7 3520M  Corsair Vengeance DDR3 2x 8GB Samsung EVO SSD Hitachi Apple Hard Drive 5400RPM 
OS
macOS Sierra 
  hide details  
Reply
fr0sty
(20 items)
 
SnowFlake
(5 items)
 
 
CPURAMHard DriveHard Drive
Intel Core i7 3520M  Corsair Vengeance DDR3 2x 8GB Samsung EVO SSD Hitachi Apple Hard Drive 5400RPM 
OS
macOS Sierra 
  hide details  
Reply
post #677 of 1143
Quote:
Originally Posted by Icekilla View Post

Hey guys. I'm trying to generate a bunch of struct arrays for a program I'm creating, but for some reason it won't work.

Here's the code in C
Warning: Spoiler! (Click to show)
Code:
#include <stdio.h>
#include <stdlib.h>

typedef struct{
    int clave;
    char nombre[50];
}DataBox;

typedef DataBox RegistroOrdenable;

int main()
{
    int n = 20000;
    RegistroOrdenable orig_box1[n];
    RegistroOrdenable orig_box2[n];
    RegistroOrdenable orig_box3[n]; //burbuja
    RegistroOrdenable box1[n];
    RegistroOrdenable box2[n];
    RegistroOrdenable box3[n];
    RegistroOrdenable box4[n];
    RegistroOrdenable box5[n];
    RegistroOrdenable box6[n];
    RegistroOrdenable box7[n];
    RegistroOrdenable box8[n];
    RegistroOrdenable box9[n];
    RegistroOrdenable box10[n];
    RegistroOrdenable box11[n];
    RegistroOrdenable box12[n]; //seleccion
    RegistroOrdenable box13[n];
    RegistroOrdenable box14[n];
    RegistroOrdenable box15[n]; //shellsort


    printf("Hello world!\n");

    return 0;
}
Warning: Spoiler! (Click to show)

It manages to create orig_box1, but when it tries to generate orig_box 2 then the compiler throws a SIGSEV signal, segmentation fault. For some reason it works for up to 2,000 blocks in each array, but above that, it won't work.

Is there any way to fix this? I'm thinking I'll have to use dynamic memory for this. frown.gif
Because you have such a high number of static declarations so many times, you're trying to allocate a higher value than the stack will allow. You'll have to use dynamic allocation (which draws from the heap).
Router
(12 items)
 
  
Reply
Router
(12 items)
 
  
Reply
post #678 of 1143
Quote:
Originally Posted by tompsonn View Post

+1
Pretty much wouldn't even bother looking any further past this sort of implementation.
If you're loading from a file to a text box for no benefit other than to just use the contents of the file, you can skip the text box step.

I ended up using the timer since task delay was giving me trouble, i got it to send emails but it sent like 3 emails per email address.

I want to send 1 email to 1 person per tick
Edited by andyroo89 - 5/29/13 at 9:45pm
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
post #679 of 1143
Quote:
Originally Posted by andyroo89 View Post

I ended up using the timer since task delay was giving me trouble, i got it to send emails but it sent like 3 emails per email address.

I want to send 1 email to 1 person per tick

Throw the code on a separate thread and use Thread.Sleep to provide your "tick".
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #680 of 1143
Quote:
Originally Posted by tompsonn View Post

Throw the code on a separate thread and use Thread.Sleep to provide your "tick".

Here is my source code, I was messing with it so much last night it maybe a bit messy.

http://pastebin.com/eUagPR6C
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programmers' lounge. (Programming-related discussions only)