-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import os.path as op | ||
from email.mime.multipart import MIMEMultipart | ||
from email.mime.base import MIMEBase | ||
from email.utils import COMMASPACE, formatdate | ||
from email import encoders | ||
from email.mime.text import MIMEText | ||
import smtplib | ||
|
||
receiver = [""] #the receiver mail | ||
list = open("list_of_mails.txt", "r") | ||
lines = list.read().split() | ||
for mail in lines: | ||
# print(line) | ||
# print(repr(line)) | ||
sender = mail | ||
|
||
# list = open("list_of_mails.txt", "r") | ||
# for mail in list: | ||
# #print(mail) | ||
# #print(repr(mail)) #[1:-1] | ||
# sender = mail.rstrip('\n') | ||
# #print(repr(sender)) #[1:-1] | ||
# #print(sender) | ||
|
||
# message info | ||
msg = MIMEMultipart() | ||
part = MIMEBase('application', "octet-stream") | ||
part.set_payload(open("scan.pdf", "rb").read()) | ||
encoders.encode_base64(part) | ||
part.add_header('Content-Disposition', 'attachment; filename="scan.pdf"') | ||
msg.attach(part) | ||
|
||
msg = MIMEMultipart() | ||
msg['From'] = sender | ||
msg['To'] = COMMASPACE.join(receiver) | ||
msg['Date'] = formatdate(localtime=True) | ||
msg['Subject'] = "print" | ||
msg['Message-ID'] = "" | ||
part = MIMEBase('application', "pdf") | ||
with open("scan.pdf", 'rb') as file: | ||
part.set_payload(file.read()) | ||
encoders.encode_base64(part) | ||
part.add_header('Content-Disposition', | ||
'attachment; filename="{}"'.format(op.basename("scan.pdf"))) | ||
part.add_header('X-Attachment-Id', "") #add Id | ||
part.add_header('Content-ID', "") #add Id | ||
|
||
msg.attach(part) | ||
|
||
with smtplib.SMTP("", 25) as server: # add smtp connection | ||
server.starttls() | ||
server.ehlo() | ||
server.login("apikey","") # add API KEY | ||
server.sendmail(sender, receiver, msg.as_string()) | ||
server.quit() | ||
print("mail sent from: " + mail) | ||
|
||
print("finished.... ^-^") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNet.Identity; | ||
using System.DirectoryServices.AccountManagement; | ||
using System.DirectoryServices; | ||
namespace ConsoleApp1 | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
|
||
PrincipalContext l_context; | ||
UserPrincipal l_user; | ||
string ourUser; | ||
try | ||
{ | ||
|
||
System.IO.StreamReader file = new System.IO.StreamReader(@"users_names.txt"); | ||
string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); | ||
|
||
while ((ourUser = file.ReadLine()) != null) | ||
{ | ||
l_context = new PrincipalContext(ContextType.Domain); | ||
l_user = UserPrincipal.FindByIdentity(l_context, IdentityType.SamAccountName, ourUser); | ||
if (l_user.HomeDirectory != null) | ||
{ | ||
Console.WriteLine(l_user.DisplayName + " " + l_user.EmailAddress); | ||
} | ||
} | ||
} | ||
catch (IOException e) | ||
{ | ||
Console.WriteLine("The file could not be read:"); | ||
Console.WriteLine(e.Message); | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.