Alright it doesnt work..so forget it in my almost a year of coding I cant send email...wow...
thanks anyway
Alright it doesnt work..so forget it in my almost a year of coding I cant send email...wow...
thanks anyway
How long does it take to send typically? The console just blinks maybe im too impatient...
Thanks pritaeas i feel stupid now but thanks.
I followed a tutuorial to send gmails through a C# app.
Im making a console app and this code fails I have no idea whats wrong...
class MainClass
{
public static void Main (string[] args)
{
sendMail mailSend = new sendMail();
mailSend.mail("stmp.gmail.com",465,"sendersemail@gmail.com","senders password","fromadress@gmail.com","toadress@gmail.com","Subject","Body",true);
}
}
public class sendMail
{
public void mail(string host, int port, string userName, string pswd, string fromAddress, string toAddress, string body, string subject, bool sslEnabled) {
MailMessage msg = new MailMessage(new MailAddress(fromAddress), new MailAddress(toAddress)); // Create a MailMessage object with a from and to address
msg.Subject = subject; // Add your subject
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = body; // Add the body of your message
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = false; // Does the body contain html
SmtpClient client = new SmtpClient(host, port); // Create an instance of SmtpClient with your smtp host and port
client.Credentials = new NetworkCredential(userName, pswd); // Assign your username and password to connect to gmail
client.EnableSsl = sslEnabled; // Enable SSL
try {
client.Send(msg); // Try to send your message
Console.WriteLine("Sent!");
}
catch {
Console.WriteLine("Failed");
}
}
Help PLEASE! This is so frustrating....
But why? He didn't explain the benefits of C++. Does the api only work on C++?
Why would a lower level language help?
I have a few things I want to make that I havent yet so this will be a later project but I was just wondering,
How would a anti virus program work in C#?
I've seen ones on youtube that iterate through your HD and looks for keywords like "Virus","Trojan" and thats basically useless..
So how should a antivirus program detect if its a malicious file?
Thanks!
I need help making some key that if the "a" key is pressed it plays a sound.
All the tutorials ive seen confuse me so maybe you can help. I've tried a few things but am still confused.
Thanks!
How can you play a sound file that resides in the solutions resources file?
Heres what I have.....
private void whiteKey1_Click(object sender, EventArgs e)
{
//If clicked
System.Media.SoundPlayer player = new System.Media.SoundPlayer("WindowsPiano.Windows_XP_Ding.wav");
player.Play();
}
I'm making a virtual piano and when the key is pressed it plays a sound...
I'm a fairly advance Python programmer. I'm am making a text based RPG which is easy for my skill but I've been wanting to learn XML for my C# project especially.
My RPG is HEAVILY inspired by fallout 3. I love the dialogue options and I want to write an xml file to store the dialouge for each NPC. So basically a giant If statement in an XML file.
FOR "Too Long Did not Read"
How can I make a XML file that holds a big if statement and how can you incorporate it into python.
I found this tutorial which is basicaly my idea except using a dictionary for the keywords instead of a key.
http://ai-programming.com/csharp_bot_tutorial.htm
Thats good enough for now.
Never heard of it....
why would i need it?
I want to make a smarter child program. Smarter Child incase you don't know was an aim bot that was designed for kids. It was extremely abused but it had pretty good AI and comprehension of what your type.
I don't really know how on this. I would probably be a C# console application because an interface isn't necessary.
I was thinking i could have multiple word banks (lists) that held different things. For example if the user typed in "Hello" it would belong to the Greetings word bank and the program would respond with a response from another word bank containing things like "How are you?".
It would analyze what is typed in and responded based on what word bank it belongs. Of course there would have to be some sort of default word bank answer if the input isn't anything.
Is that a viable idea to make this off of?
I dont know querys but C# has a DateTime.Now method that might help?
I'm working on an xbl stat grabber. I have a problem I dont understand how to get the "gamer card"
Heres an example : http://www.youtube.com/watch?v=6HA-uz_v6A0&feature=related
I already have the avatar but I don't get how you can grab the stats and recent games...
I really have no exerience with C# and getting stuff form web sites so im lost..i also suck at C#.
Thanks!
ah, I thought I had to save it in another variable. Didn't think of value.
I tried that apegram but,
The code when printed only produces "System.Random"...
public static void GenerateSentence()
{
List<string> nouns = new List<string> { "He", "She", "Him", "Billy Bob", "Mike", "Noah"};
List<string> verbs = new List<string> {"runs","eats","doesn't like"};
Random noun_rand = new Random();
int index = noun_rand.Next(0,6); // list.Count for List<T>
string value = nouns[index]; // where array is string[]
Console.WriteLine(noun_rand);
Console.ReadLine();
}
How can I randomly pick a string element out of a list or array?
I'm making a typing aid and I have a method that contains lists of noun/adjectives and verbs. I need it to pick one thing out of each list and turn it into a sentence.
I think im just gonna give this one up. I rushed into it and its all wrong...
Yeah, Theres alot of things I havent got to yet.
But since hit the input variable and the function hit and named the same they cause an error?
So I got bored and made a blackjack game. This is probably be the last thing I code in python before I move to C#!!!(so excited to learn it)
The game() function is the main fuction all the rest are pretty self explanatory if you understand blackjack. My issue is that when you deal the cards and it ask if you want to hit it gives me an error no matter the input.
#Black Jack
import random
# Main function
def game():
computerHand = deal()
playerHand = deal()
print "Welcome to Blackjack!"
print "---START GAME---"
#begin/deal the card
start=raw_input("Deal cards? [Y/N]")
global playerHand
global computerHand
if start=="Y" or "y":
print "Your cards are: "+str(playerHand)
print "Dealer's Cards are:"+str(computerHand)
hit=raw_input("Do you want to hit? [Y/N] ")
if hit=="Y" or "y":
hit()
#check it hit busted player
bust()
print str(playerHand)
else:
print "You stand with"+str(playerHand)
else:
print "Fine then, Don't play..."
#Deal player/comp new hand
def deal():
random1 = random.randint(1,14)
random2 = random.randint(1,14)
#first card/Converts face card to accual value
if random1 == 11:
random1 = "J"
if random1 == 12:
random1 = "Q"
if random1 == 13:
random1 = "K"
if random1 == 14:
random1 = "A"
#second card
if random2 == 11:
random2 = "J"
if random2 == 12:
random2 = "Q"
if random2 == 13:
random2 = "K"
if random2 == 14:
random2 = "A"
hand = [random1,random2]
return hand
def hit():
newCard = random.randint(1,14)
if newCard == 11:
newCard = "J"
if newCard == 12:
newCard …
It's using the email address most service providers provide to send texts from an email accounts.(phonenumber@service.com)
My program asks the user for recipients number/service provider plugs it into the email(above) then prompts the user for the message and sends it.
If you have a better way to send texts like the sms gateway. I'll take any ideas, this way the only way I knew how to do this.
I know the code for sending mail is.
import smtplib
fromaddr = 'fromuser@gmail.com'
toaddrs = 'touser@gmail.com'
msg = 'There was a terrible error that occured and I wanted you to know!'
# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
Basically its a program that allows people to send messages to phones via texts from your computer for free. So i won't know any of their stmp data
how can I find it out?
Thanks!
Well I tried learning this cause I wanted to make my own game like this (didn't stick with me) but you'll need to learn a couple of things.
Php to handle players stats and other stuff in a mysql database.
javascript for programming the actual game.
You might want to learn HTML too just because it'll help build the site your game live in.
Im trying to make a bac calculator and make a gui for it but am having issues with the math code for it.
Here's my code. Everything I input returns 0.
The BAC forumula is (150/body weight)(% alcohol/50)(ounces consumed)(0.025). Btw, I suck at math so it could be a math error....
class main():
def bac(self):
drink=raw_input("What kind of drink was it? 12oz. ([B]eer, 5oz. [W]ine, 1.25oz. [S]hot) ")
if drink=="b":
weight=raw_input("What is your Body weight in pounds? ")
w=150.0/int(weight) #body weight
q=.04/50 #beer alcohol content
z=raw_input("How many drink were consumed? ") #consumed ounces
x=0.025
bac=int(w)*int(q)*int(z)*int(x)
print bac
Let's Put it this way. How long will it take me to learn as3 and make a new grounds acceptable game vs. C# and a XNLA acceptable game?
I have a background in python and I'm looking for a new language. I am almost only interested in making games.
I have come to 2 languages. C# and Action Script.
C# because Microsoft allows you to make Indie XBLA games programmed in C# ONLY.
Action Script so I can make flash games for new grounds and have a bigger audience.
What do you think is better to learn in the long run?
I have a little background in Python, but I want to move on to learning C# (Im not giving up on Python, I'm still coding in it). I choose C# so I can make games to submit to XNA, so I can get some games on XBLA.
Anyway every tutorial on the internet seems to suck at C#. I can't find a complete series of tutorials that explain C# as a whole and not just making one app. So I'm planning on purchasing a book. Does anyone have any suggestions for me?
-Thanks,
Noah
Also, How can i make this codes with mysql workbench...
Like how many rows/collums ect.
CREATE TABLE users (
id int NOT NULL AUTO_INCREMENT,
username varchar(250),
password varchar(50),
PRIMARY KEY(id)
);
I have MySql Workbench, Is that good or should i get phpmyadmin?
This doesn't really have anything to do with Php but I'm following a php tutorial so...I've NEVER used any database system before...
Anyway,
I'm following this tutorial,
http://buildingbrowsergames.com/2008/04/15/designing-your-database/
I'm up to the part where your making the user sql table in the tutorial. I have no idea where to input that code..
Where do you put the code?
CREATE TABLE users (
id int NOT NULL AUTO_INCREMENT,
username varchar(250),
password varchar(50),
PRIMARY KEY(id)
);
Pythons awesome. btw nice youtube channel. I'm 13 too :)
can you animate anything or bring in buttons ect. like in flash even outside the ide itself?
thanks for the info btw
I want to make Flash games like on addicting games, BUT $700 for Adobe Flash!?! I can't afford that!
So how can i use an Adobe Flash alternative and to make games?
What if i wanted to use xcode with python? Can I?
would i also be able to use interface builder for gui's?
I need this code to ask if you finished the current quest, if your say YES you have, i must check your inventory to see if you have the necessary items to complete it.
What will check if inventory contains flour and eggs in this case?
Thanks, (code below)
#Tavern Class
class tavern():
def taver_n(self):
if currnt_quest=="Chef's Helper":
done=raw_input("Bar Broski: You finish the quest yet? [yes/no] ")
if done=="yes": #MUST CONFIRM FLOUR/EGGS IS IN INV
print "Bar Broski: Great Job! Here's $500 for your troble..."
print "Reward 100xp!"
print "Trav MCcoy: Welcome to my tavern. Many of the locals here have odd jobs for people that you can do. Quests give you exp to level up so do as many as you can."
finishquest=raw_input("Are Ya Looking for a ")
quest_list=("1)Chef's Helper")
quest=raw_input("Bar Browski:Hey, You intrested in a quest? [yes/no] ")
if quest=="yes":
#link to menu
manu=menu()
manu.main_menu()
else:
print "Bar Browski: Alright another time then."
#link to menu
manu=menu()
manu.main_menu()
Aww no mac version though...
I use textwrangler for osx right now, but i want to see what other free ide's are out there. Is there one with tabs for classes and object to be separated?
Thanks to everyone who helped me. Wrting it in class is so much better and easier to understand. Thanks once again.
Yes, follow the style guide.
But 2 spaces is so much easier to type, and easy enough to read for me, so I break the rules for that reason.
Of course, I use 4-spaces if the IDE (Visual Studio) does it for me.
You are right though, Python programmers should follow the style guide. I was wrong to encourage it, but I still admit to doing it :).
My code is so ugly. Its good that im using classes to organize it so i dont get lost when im error correcting. Normally my indents are 1 tab space but i got lazy.
Yep. I think i got a good idea on classes now and shall be using them more to organize my code. thanks you very much jcao219
Ok, i wanna learn C languages next so im going to start using classes and objects now.
class collect_data():
def collect_data():
first name?
last name?
ect.
class menu():
def what_todo():
"create code? or search?"
class search():
def searching():
#search algorithem
collectObject=collect_data()
collectObject.collect_data
In bad pusedo code is that how you use classes?
Would you put the classes outside the main block of code and use objects to acsess the functions inside the classes?
couldn't you just define functions and skip all the classes?
So according to my uncle a season programmer (not in python)
I should make a class to hold an objects and each object is a individual contact.
But it still isn't working. Im getting SO FRUSTRATED!! arhg i need help...
#MyContact CLASS
class MyContact():
firstName=""
lastName=""
Phone=""
Email=""
Address=""
#what to do
print ""
action=raw_input("Are you [1]Creating entrys or [2]Searching for existing entrys? ")
# IF Creating or editing
if action=='1':
action2=raw_input("Would you like to create a [1]new entry or [2]edit an existing one? ")
#if creating new
if action2=='1':
while 1:
contact = MyContact()
contact.firstName=raw_input("First Name: ")
contact.lastName=raw_input("Last Name: ")
contact.Phone=raw_input("Phone: ")
contact.Email=raw_input("Email: ")
contact.Address=raw_input("Adress: ")
fob=open("bookdata.txt",'w')
fob.write("\n" + contact.firstName + ", " + contact.lastName + ", " + contact.Phone + ", " + contact.Email + ", " + contact.Address + "\n")
fob.close()
#creating another contact
cont=raw_input("Would You Like to create another Contact? [yes/no]")
if cont=='no':
break
else:
pass
/n wont work. The new line command is \n.
Heres the update version of that code block.
I saved it to 'temp1' and normaly you would delete lines like so, "temp1[2]='sdfase' " and change it that way. BUT i dont know the list number of the contact so im lost one again...
#if editing
if action2=='2':
fob=open('bookdata.txt','r')
searchcriteria=raw_input("Enter the name of the contact you'd like to delete: ")
temp1=fob.readlines()
for line in temp1:
if searchcriteria in line:
temp1[list]=""
#confirm this is the contact you want to delete
#confirmdel=raw_input("Is That the contact you wish to delete? [yes or no]")
#if confirmdel=="yes":
How can i use this code (below) to take the random numbers from the dice roll and change 6 to "A" and 5 to "K" and ect.
#Poker Dice! Noah Sutton 4/24/10
import random
rounds=0
#roll dice
def roll_dice():
#Dice variables
dice1=random.randint(1,6)
dice2=random.randint(1,6)
dice3=random.randint(1,6)
dice4=random.randint(1,6)
dice5=random.randint(1,6)
'1'=9
'2'=10
'3'=J
'4'=Q
'5'=K
'6'=A
print "You rolled "+str(dice1)+","+str(dice2)+","+str(dice3)+","+str(dice4)+","+str(dice5)
#Implement the code:
roll_dice()
tonyjv you gotta break that down..I have no idea what you mean. (am N00b)
and it for myself. i dont take programming classes.
Ok so I'm working on an address book app in python. the user writes contacts into a txt file and can search for it and everything.(run the code yourself if you want to see what it does)
now for my problem,
under "#if editing"
i want have the user search for a contact and delete that line. but i have no clue how to use remove(x), or pop(x) when working with files. Thanks
Below is my code
#what to do
print ""
action=raw_input("Are you [1]Creating/Editing entrys or [2]Searching for an existing entry? ")
# IF Creating or editing
if action=='1':
action2=raw_input("Would you like to create a [1]new entry or [2]edit an existing one? ")
#if creating new
if action2=='1':
fob=open('/Users/NSutton/Simple Adress/bookdata.txt','w')
fname=raw_input("First Name: ")
lname=raw_input("Last Name: ")
pnum=raw_input("Phone: ")
email=raw_input("Email: ")
address=raw_input("Adress: ")
fob.write(fname + " " + lname + ", " + pnum + ", " + email + ", " + address)
fob.write("\n")
fob.close()
#if editing
if action2=='2':
fob=open('/Users/NSutton/Simple Adress/bookdata.txt','r')
searchcriteria=raw_input("Enter the name of the contact you'd like to delete: ")
for line in fob:
if searchcriteria in line:
print line
#confirm this is the contact you want to delete
confirmdel=raw_input("Is That the contact you wish to delete? [yes or no]")
if confirmdel=="yes":
#IF searching
if action=='2':
fob=open('/Users/NSutton/Simple Adress/bookdata.txt','r')
searchcriteria=raw_input("Enter your search criteria (name,phone ect.): ")
for line in fob:
if searchcriteria in line:
print line
#If no data matches search
else:
print "Error: No contact matching search."