email with Visual Basic

Programming, for all ages and all languages.
engine252

email with Visual Basic

Post 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
__12awr__

Re:email with Visual Basic

Post 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.
Mr_Spam

Re:email with Visual Basic

Post by Mr_Spam »

study the I love you virus, you can do just what you want useing VBS without to much problem.
engine252

Re:email with Visual Basic

Post 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. :-\
Tim

Re:email with Visual Basic

Post by Tim »

You could use WinSock to interface directly to your SMTP server.
engine252

Re:email with Visual Basic

Post 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?
Tim

Re:email with Visual Basic

Post 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.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:email with Visual Basic

Post 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.
-- Stu --
engine252

Re:email with Visual Basic

Post 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?
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:email with Visual Basic

Post 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
-- Stu --
engine252

Re:email with Visual Basic

Post 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)
engine252

Re:email with Visual Basic

Post by engine252 »

what's up with those boundary's ?

i don't get that :'(
engine252

Re:email with Visual Basic

Post 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
jrfritz

Re:email with Visual Basic

Post by jrfritz »

Why would he not want it on the net?
engine252

Re:email with Visual Basic

Post 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)
Post Reply