HTML mail
HTML mail
HTML mail
HTML mail
HTML mail
HTML mail HTML mail HTML mail HTML mail HTML mail HTML mail HTML mail HTML mail
HTML mail HTML mail
HTML mail
Go Back  Xtreme Visual Basic Talk > > > HTML mail


Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2003, 03:00 PM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default HTML mail


I have a program that sends HTML e-mail to SUBSCRIBED customers...

For some reason, when I run a test...and display the message and send it manually (through Outlook) the formating looks fine.

If I let the program create each message and then send it automatically...does not send as an HTML file.

Is the a way to set the header information to
content-type=text/HTML to force the formatting?

Why would I get different results when it auto-sends, even though the message object is being created the same way?
Reply With Quote
  #2  
Old 01-13-2003, 03:37 AM
Ed James Ed James is offline
Regular
 
Join Date: Dec 2000
Posts: 58
Default

I don't know how you've done your code but if you set the HTMLBody property of an email item to an html string then the email content will look like the web page.

Set mItem = mOutLookApp.CreateItem(olMailItem)

mItem.HTMLBody = "<HTML><H2>My HTML page.</H2><BODY>My body.</BODY></HTML>"
Reply With Quote
  #3  
Old 01-13-2003, 07:32 AM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

One would think that that would work...and it does if I display the message before sending...

But when the message is sent automatically...it doesn't come through correctly.
Reply With Quote
  #4  
Old 01-13-2003, 12:12 PM
Ed James Ed James is offline
Regular
 
Join Date: Dec 2000
Posts: 58
Default

How do you get the program to send the mail automatically. In the following code when I call the send method on the item object it just puts it into the outbox (even with a dial up connection) and I still have to press F5 to send the message.
Any help would be appreciated. Thanks

Dim mOutLookApp As Outlook.Application
Dim mNameSpace As Outlook.NameSpace
Dim mFolder As Outlook.MAPIFolder
Dim mItem As Outlook.MailItem
Dim pRecip As Recipient

Set mOutLookApp = CreateObject("OutLook.Application.9")
Set mNameSpace = mOutLookApp.GetNamespace("MAPI")
Set mFolder = mNameSpace.GetDefaultFolder(olFolderInbox)
mFolder.Display

Set mItem = mOutLookApp.CreateItem(olMailItem)
Set pRecip = mItem.Recipients.Add("bill@somewhere.co.uk")

mItem.HTMLBody = "<HTML><H2>My HTML page.</H2><BODY>My body.</BODY></HTML>"
mItem.Subject = "Email created by VB"

mItem.Save
mItem.Send '**This just puts it into the outbox and doesn't send it**


Set mOutLookApp = Nothing
Set mNameSpace = Nothing
Set mFolder = Nothing
Set mItem = Nothing
Reply With Quote
  #5  
Old 01-13-2003, 12:40 PM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

not sure how you are setup...but I'm live on a network with the Exchange server...so anything in my outbox goes immediately.
Reply With Quote
  #6  
Old 01-14-2003, 02:36 AM
Ed James Ed James is offline
Regular
 
Join Date: Dec 2000
Posts: 58
Default

I've just stumbled upon it... The setting is in Outlook->Tools->Options->Mail Delivery->"Send Messages Immediately When Connected" otherwise it waits some specified amount of time before it sends.
Reply With Quote
  #7  
Old 01-14-2003, 07:53 AM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

Right...now if your program creates and sends HTML e-mails...without displaying them...do they go out formated?

The only difference in your code and mine is that you save the message before sending, but I'm not sure that would make a difference.
Reply With Quote
  #8  
Old 01-14-2003, 07:58 AM
peter
Guest
 
Posts: n/a
Default

sure. you need to save everything in outlook. else it doesn't do what you want it to do...
Reply With Quote
  #9  
Old 01-14-2003, 08:27 AM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

no luck....
I save the message before sending and still get the same results.

If I have my program create and then display the message before sending...and then manually hit send...all is well.

But if it creates the identical e-mail and then sends...when it leaves our domain the e-mail goes without the HTML formatting.

It makes no sense.
Reply With Quote
  #10  
Old 01-14-2003, 08:33 AM
peter
Guest
 
Posts: n/a
Default

you must specify that outlook sends mails in html format. otherwise it won't ever work. you can set this at tools>options>mail format>send in this message format and set html there. works?
Reply With Quote
  #11  
Old 01-14-2003, 08:38 AM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

Already set to HTML...that's why it works when an individual e-mail is sent.

But it seems to ignore this when everything is automated.

Are you able to send an HTML e-mail that is created by a VB application without "stopping" in outlook...

If you are using Outlook XP and get the security warning...wait the 5 seconds...then click OK....that counts as the stop...everything goes as HTML.

It is ONLY when everything is automated and the e-mail goes with not human intervention.
Reply With Quote
  #12  
Old 01-14-2003, 08:44 AM
peter
Guest
 
Posts: n/a
Default

try to set the body to the html string too.
Reply With Quote
  #13  
Old 01-14-2003, 08:57 AM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

it is....
Again it works for a single e-mail.

here is the section of code:

On Error Resume Next
Dim SafeItem '
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem
Dim body As String
Dim fs, F
Set fs = CreateObject("Scripting.FileSystemObject")
Set F = fs.OpenTextFile(App.Path & "\" & txtFILE.Text, 1, TristateFalse)
body = F.readall
Set SafeItem = CreateObject("Redemption.SafeMailItem")
Set objMail = objOutlook.CreateItem(olMailItem)
SafeItem.Item = objMail

With SafeItem
.To = Recipients
.Subject = txtSUBJECT.Text
.HTMLBody = body
If chkTEST.Value = 1 Then
.To = "egsiegel@aol.com; esiegel@ampacet.com"
.Save
' .Send
Else
.Send
End If
Set objOutlook = Nothing
Set objMail = Nothing
Set SafeItem = Nothing
End With

Set objMail = Nothing
Reply With Quote
  #14  
Old 01-14-2003, 09:08 AM
peter
Guest
 
Posts: n/a
Default

it doesn't work if you create an outlook mail item, set the body and the HTMLbody property to "<html><body><h1>test</h1></body></html>", save and send it?
Reply With Quote
  #15  
Old 01-14-2003, 09:10 AM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

nope
Reply With Quote
  #16  
Old 01-14-2003, 09:11 AM
peter
Guest
 
Posts: n/a
Default

what version of ol do you have?
Reply With Quote
  #17  
Old 01-14-2003, 09:15 AM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

Outlook is XP that is why I need to use the Outlook Redemtion com to bypass the security warning...
However I have another version of this program that does not use the SafeItems...just straight Outlook objects that I have tested on Outlook 2000....same deal.
Reply With Quote
  #18  
Old 01-14-2003, 09:41 AM
peter
Guest
 
Posts: n/a
Default

do you try to send the mails from outlook? I mean, is your macro in outlook?
Reply With Quote
  #19  
Old 01-14-2003, 09:43 AM
ESiegel's Avatar
ESiegel ESiegel is offline
Centurion
 
Join Date: Feb 2002
Location: New York
Posts: 107
Default

no...
Code is a VB program...and is listed above.
Reply With Quote
  #20  
Old 01-14-2003, 09:46 AM
peter
Guest
 
Posts: n/a
Default

why do you send it through outlook? send it through vb, then there is no problem..
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
HTML mail
HTML mail
HTML mail HTML mail
HTML mail
HTML mail
HTML mail HTML mail HTML mail HTML mail HTML mail HTML mail HTML mail
HTML mail
HTML mail
 
HTML mail
HTML mail
 
-->