🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #49383

Re: MAPISendMail / Post to a Newsgroup

#49383
From: michael (michka) kaplan
Date: Tue, 12 Dec 2000 07:45
241 lines
8867 bytes
Well, there is a good way to make Unicode calls, a deprecated way, and a bad
way. You chose the bad way. :-)

With that said, I would proceed and do it the right way.... make the string
params longs and then use StrPtr() of the strings for the long to pass.

--
MichKa

a new book on internationalization in VB at
http://www.i18nWithVB.com/

"Lyle Fairfield" <lylefair@yahoo.com> wrote in message
news:Xns90075F915lylefairyahoocom@24.2.9.58...
> Michael
>
> I'm quite willing to accept the notion that there could be
> addressing problems in this procedure with other than ANSI
> character sets.
>
> But the issue here was or is:
> Can we send mail from Access with OE, regardless of our default
> mail client? Some people have asserted that this cannot be done.
> I think I can say that I can, as I have done so, and am willing
> to do so to anyone who doubts this.
>
> The addressing does not accept the address string unless it is
> converted from Unicode, or rather it accepts it but truncates it
> to one character, the "s" in "smtp". If there is another way to
> induce the procedure to use the address, I would be glad to know
> it.
>
> As for, "you should never be using MAPISendMail from a provider-
> specific DLL", I expect that you are right, but that was,
> essentially, the problem. Would I ever use this myself? I doubt
> it. Outlook and CDO seem to provide easier and more efficient
> avenues for this.
>
> "michael \(michka\) kaplan"
> <former_mvp@nospam.trigeminal.spamfree.com> wrote in
> <t39jvdcpku0sa5@corp.supernews.com>:
>
> >Well, since you should never be using MAPISendMail from a
> >provider-specific DLL, that could be the other problem?
> >
> >But lets ignore that for a moment. :-)
> >
> >I will explain what is wrong with this approach to handling
> >Unicode strings. Pretend that I were sending your name to the
> >dll. VBA stores the string as Unicode, thus:
> >
> >L0y0l0e0
> >
> >(zeros mean null zero). When you do the StrConv call, VBA
> >makes a MultiByteToWideChar call on your behalf via CP_ACP
> >and you make it
> >
> >L000y000l000e000
> >
> >This is of course not something found in nature.... Double
> >Unicode? Sounds like a Animal housish "Double-secret
> >Unicode?" You pass this to the API, and VBA obligingly
> >converts it back via WideCharToMultiByte to:
> >
> >L0y0l0e0
> >
> >So, no harm done, right? You just needlessly copied some
> >strings? Leaving aside the negative perf implications, lets
> >pretend that your name contained some Kanji in it, because
> >you were Japanese. On your Japanese machine, it turns out
> >that some of the characters that show up in "double-secret
> >Unicode" are illegal and replaced by question marks. You end
> >up sending along
> >
> >L0?0?0e0
> >
> >and then of course chaos erupts, the earth turns a bit
> >slower, and we all fall off the planet since we do not slow
> >down any. :-)
> >
> >StrConv should never be used that way. Hell, you should not
> >even use byte arrays.
> >
> >You can see this issue described in my book, or if you are a
> >consciencious objector to the idea of me making money (and
> >some people are!) then Matt Curland also covers this topic in
> >his excellent book.
> >
> >--
> >MichKa
> >
> >a new book on internationalization in VB at
> >http://www.i18nWithVB.com/
> >
> >"Lyle Fairfield" <lylefair@yahoo.com> wrote in message
> >news:Xns9006B3BF6lylefairyahoocom@24.2.9.58...
> >> Actually I would want to do this, else OE seems to
> >> interpret the first zero it comes to as end of string and
> >> so I send it to a one letter address of "s".
> >>
> >> Perhaps, you would like to try it:
> >>
> >> Option Explicit
> >>
> >> Type MAPIRecip
> >>     Reserved As Long
> >>     RecipClass As Long
> >>     Name As String
> >>     Address As String
> >>     EIDSize As Long
> >>     EntryID As String
> >> End Type
> >>
> >> Type MAPIFileTag
> >>     Reserved As Long
> >>     TagLength As Long
> >>     Tag() As Byte
> >>     EncodingLength As Long
> >>     Encoding() As Byte
> >> End Type
> >>
> >> Type MAPIFile
> >>     Reserved As Long
> >>     Flags As Long
> >>     Position As Long
> >>     PathName As String
> >>     FileName As String
> >>     FileType As MAPIFileTag
> >> End Type
> >>
> >> Type MAPIMessage
> >>     Reserved As Long
> >>     Subject As String
> >>     NoteText As String
> >>     MessageType As String
> >>     DateReceived As String
> >>     ConversationID As String
> >>     Originator As Long
> >>     Flags As Long
> >>     RecipCount As Long
> >>     Recipients As Long
> >>     Files As Long
> >>     FileCount As Long
> >> End Type
> >>
> >> Declare Function MAPISendMail _
> >>     Lib "c:\program files\outlook express\msoe.dll" ( _
> >>     ByVal Session As Long, _
> >>     ByVal UIParam As Long, _
> >>     message As MAPIMessage, _
> >>     ByVal Flags As Long, _
> >>     ByVal Reserved As Long) As Long
> >>
> >> Sub SendMailWithOE(ByVal strSubject As String, ByVal
> >> strMessage As String, ByRef aRecips As Variant)
> >>     Dim recips() As MAPIRecip
> >>     Dim message As MAPIMessage
> >>     Dim z As Long
> >>     ReDim recips(LBound(aRecips) To UBound(aRecips))
> >>     For z = LBound(aRecips) To UBound(aRecips)
> >>         With recips(z)
> >>             .RecipClass = 1
> >>             If InStr(aRecips(z), "@") <> 0 Then
> >>                 .Address = StrConv(aRecips(z),
> >>                 vbFromUnicode)
> >>             Else
> >>                 .Name = StrConv(aRecips(z), vbFromUnicode)
> >>             End If
> >>         End With
> >>     Next z
> >>     With message
> >>         .NoteText = strMessage
> >>         .Subject = strSubject
> >>         .RecipCount = UBound(recips) - LBound(aRecips) + 1
> >>         .Recipients = VarPtr(recips(LBound(recips)))
> >>     End With
> >>     MAPISendMail 0, 0, message, 0, 0
> >> End Sub
> >>
> >> Sub TestSendMailwithOE()
> >>     Dim aRecips(0 To 0) As String
> >>     aRecips(0) = "smtp:lylefair@yahoo.com"
> >>     SendMailWithOE "Test", Format(Now(), "yyyy-mm-dd
> >>     hh:nn"),
> >> aRecips
> >> End Sub
> >>
> >>
> >>
> >> "michael \(michka\) kaplan"
> >> <former_mvp@nospam.trigeminal.spamfree.com> wrote in
> >> <t3837ukr5gj3a1@corp.supernews.com>:
> >>
> >> >Also, you would not want to do this StrConv trick with the
> >> >call, anyway.
> >> >
> >> >--
> >> >MichKa
> >> >
> >> >a new book on internationalization in VB at
> >> >http://www.i18nWithVB.com/
> >> >
> >> >"michael (michka) kaplan"
> >> ><former_mvp@nospam.trigeminal.spamfree.com> wrote in
> >> ><message
> >> >news:t2n2tn369a5caf@corp.supernews.com...
> >> >> MAPISendMail (simple MAPI) does not support the NNTP
> >> >> protocol.
> >> >>
> >> >> --
> >> >> MichKa
> >> >>
> >> >> a new book on internationalization in VB at
> >> >> http://www.i18nWithVB.com/
> >> >>
> >> >> "Lyle Fairfield" <lylefair@yahoo.com> wrote in message
> >> >> news:90004DFD0lylefairyahoocom@24.2.9.58...
> >> >> > Can I use MAPISendMail to post to a newsgroup?
> >> >> >
> >> >> > Currently I am using the address included below. A
> >> >> > message sent to this
> >> >> address
> >> >> > seems to go somewhere, as it is not returned and does
> >> >> > the Mail Admin
> >> >does
> >> >> not
> >> >> > generate an error response (which happens for other
> >> >> > addresses):
> >> >> >
> >> >> > With Recipient(0)
> >> >> >     .RecipClass = 1
> >> >> >      .Address = StrConv("nntp://comp.databases.ms-
> >> >> > access@news1.rdc2.pa.home.com", vbFromUnicode)
> >> >> > End With
>
> --
> Lyle
> http://www.cyriv.com/


Technical Details
Message-ID: <t3blt491060q44@corp.supernews.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!supernews.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
References: <90004DFD0lylefairyahoocom@24.2.9.58> <t2n2tn369a5caf@corp.supernews.com> <t3837ukr5gj3a1@corp.supernews.com> <Xns9006B3BF6lylefairyahoocom@24.2.9.58> <t39jvdcpku0sa5@corp.supernews.com> <Xns90075F915lylefairyahoocom@24.2.9.58>

Show Full Headers
Complete Article Headers
Message-ID: <t3blt491060q44@corp.supernews.com>
Subject: Re: MAPISendMail / Post to a Newsgroup
Date: Mon, 11 Dec 2000 23:45:07 -0800
From: "michael \(michka\) kaplan" <former_mvp@nospam.trigeminal.spamfree.com>
References: <90004DFD0lylefairyahoocom@24.2.9.58> <t2n2tn369a5caf@corp.supernews.com> <t3837ukr5gj3a1@corp.supernews.com> <Xns9006B3BF6lylefairyahoocom@24.2.9.58> <t39jvdcpku0sa5@corp.supernews.com> <Xns90075F915lylefairyahoocom@24.2.9.58>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!supernews.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
Newsgroups: news.software.nntp,comp.databases.ms-access
Organization: Posted via Supernews, http://www.supernews.com
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-Complaints-To: newsabuse@supernews.com
Lines: 240