Page 1 of 2

email with Visual Basic

Posted: Thu Dec 05, 2002 2:53 pm
by engine252
I'm making a program that should mail automaticly
but everytime i run my code i ged a dialogbox from
outlook with a warning for the user to alow this action
i don't want that is there a way to supres the dialog or a other way to mail in vb.

i saw some code ones that used winsock but that didn't
supported attachment my code chould support attachements

anyone who hase a solution let me know.


thats code i tried that gives the dialogs
------------------------------------------------------------------------
Private Sub Command1_Click()

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
Set myRecipient = myItem.Recipients.Add("[email protected]")
myAttachments.Add "C:\Map1.xls", _
olByValue, 1, "Grafiek met resultaten 4e kwartaal 1996"


myItem.Send

End Sub

Re:email with Visual Basic

Posted: Thu Dec 05, 2002 3:50 pm
by __12awr__
Well, your VB uses MAPI, and outlook uses security that askes the user if they want to e-mail that so a virus can't automaticly just email stuff. So, either you could make a program that e-mails your stuff, or make your program manuley e-mail, or you could make your program act like a virus, by supressing that dialog some how, and make Virus scanners and people think that your program is a virus.

Re:email with Visual Basic

Posted: Thu Dec 05, 2002 11:45 pm
by Mr_Spam
study the I love you virus, you can do just what you want useing VBS without to much problem.

Re:email with Visual Basic

Posted: Fri Dec 06, 2002 3:59 am
by engine252
im not trying to make a virus here...

my program should mail something at night when nobody is around and thats why i can't have the dialog boxes becuals nobody is there to answer them.

if you got a solution please help me then. :-\

Re:email with Visual Basic

Posted: Fri Dec 06, 2002 8:15 am
by Tim
You could use WinSock to interface directly to your SMTP server.

Re:email with Visual Basic

Posted: Fri Dec 06, 2002 8:19 am
by engine252
i tryed winsock but it's not very simple to attach a file i cinda hoped some of you could help me out i tryed the winsock page but they are very theoretical and only
give an example on how to code and decode the attache file. if any of you hase a good sample using winsock let me know?

Re:email with Visual Basic

Posted: Fri Dec 06, 2002 1:14 pm
by Tim
WinSock won't let you send emails per se, but it will allow you to connect to your ISP's SMTP server and send an email that way. WinSock will let you send and receive raw bytes. Read the RFC for SMTP.

Alternatively, you could get an SMTP control.

Re:email with Visual Basic

Posted: Fri Dec 06, 2002 5:29 pm
by df
this msgbox is a 'feature' of outlook to stop viruses from sending. which is a big PITA at my work, since we automate lots of things and use automated emails.

i wrote my own SMTP control with the RFC's and added base64 encoding for attachments, etc. its really easy to do.

all you need is the winsock control and use tcp/ip to te smptp server.

i cant give you my control tho ;) my company owns it all. but it really is quite simple.

Re:email with Visual Basic

Posted: Sat Dec 07, 2002 5:28 am
by engine252
can you a least help me out then i got a function doing the mail but should i add the base64 coded file in the body part or after the body part or how should can i let the server know i want to add an attachment?

Re:email with Visual Basic

Posted: Sat Dec 07, 2002 6:31 am
by df
you need to generate a mime multipart message.

so you have

mime header 1
mime2
message
mime2end
mime3
attachment
mime3end
mime4
attachment
mime4end
mime end 1

etc
its all one big text file you send to the server

Re:email with Visual Basic

Posted: Sat Dec 07, 2002 8:17 am
by engine252
thanks you helped me alot i'm almost finnished with the project i'll post my functions then so for ones everybody can use them

i'll be famous ;D 8)

Re:email with Visual Basic

Posted: Sat Dec 07, 2002 9:02 am
by engine252
what's up with those boundary's ?

i don't get that :'(

Re:email with Visual Basic

Posted: Fri Dec 13, 2002 4:16 am
by engine252
i managed to send mail with attachment throu winsock
if your interrested mail me i had help of a friend and he asked not to put it on the net but i'm happy to help thou

Re:email with Visual Basic

Posted: Sun Dec 15, 2002 4:17 pm
by jrfritz
Why would he not want it on the net?

Re:email with Visual Basic

Posted: Mon Dec 23, 2002 3:31 pm
by engine252
becouls there is practicaly nobody who realy knows how to send attachments and if you take a look at it its' quit simple,but i respect my friend... so unless you are realy interrested in that pease of code i will not put it on the net. i'd be glad to send it to ya if you would want to take a look at it. 8)